Jump to content

[SOLVED] Display an ALT tag when an image is missing...


JTapp

Recommended Posts

Does anybody know how I can display the ALT words "The image is not available" to the following line - so I can get rid of that little red "x" when the image isn't available?

 

 

echo "<img src='" . $imagesFolder . $row['CompanyID'] . ".jpg' /></p>";

 

Link to comment
Share on other sites

I'm no expert (just waiting for my question to be answered, but...

 

$imagelink = $imagesFolder.$row['CompanyID'];

if (file_exists($imagelink)) {
echo "<img src='".$imagelink.".jpg' /></p>";
} else {
echo "<img src='".$imagelink.".jpg' alt='The image is not available' /></p>";
}

 

should work?

Link to comment
Share on other sites

Well, how about just this? (unless I didn't read the thread properly and it has to be an alt tag)

 

<?php
$imagefile = "$imagesFolder{$row['CompanyID']}.jpg";
if (file_exists($imagefile))
echo "<img src='$imagefile' />";
else
    echo "The image is not available";
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.