Is it possible to display an alternative image please?

A

Anonymous

Guest
Hello.

I'd just like to enquire if an image is not available for some reason, is it possible to show an alternative image instead?

At present I've written

Code:
<img src="/user/images/<?=row['myimage'?>", width="75",  height="75", alt="scr='/system/graphics/noimage.png'">

At present, it displays the text scr='/system/graphics/noimage.png' but I'd like it to display the noimage.png graphic.


Thank You.
 
Yes you can always use alternate image if your image does not exist. You can use file_exists() php function.

$image="path of image/image.png";

if(file_exists($image))
{
echo "<img src="’.$image.’"/>";
}
else
{
echo "<img src="path of your default image/noprofile.png">";
}
 
Back
Top