Click to See Complete Forum and Search --> : Hiding low res images if not available


peter cadogan
08-24-2006, 01:59 AM
Hi - this is the first time I have tried this :-)
I am building pages that use low res images to link to high res images that will open in a separate window when clicked on. The idea here is that these images can be uploaded to the site as jpg files having the appropriate filename without having to rebuild the html pages. But if neither image is available, I would like to be able to hide the empty image box completely, rather than have it display as a missing image box. One way to do this is to have very small "dummy" low res images that match the colour of the background, so would effectively disappear. But this means I would need to make thousands of copies of this tiny image, each with a different name. Is there a better way?

Kravvitz
08-24-2006, 03:22 AM
So why don't you use a server-side language to check if the image is where it's supposed to be?

peter cadogan
09-04-2006, 01:53 AM
Thanks for the reply. I'm rather new to this, and have yet to discover how to do things like this on the server side. I just thought that I might be able to do it in straight HTML and it seems not. So it looks like I've go some more reading to do :-)
Peter

sincilite
09-04-2006, 03:19 AM
in PHP you can use the file_exists() function to find if the file.... erm exists!

So something like this:

if(file_exists("images/image.jpg")) {
echo <img src='images/image.jpg' alt='My Image' />
}

mueller
09-04-2006, 04:40 AM
How about setting the image as a background image of a div tag? Something like this:

<div style="background-image:url(yourimage.gif)">
<a href="http://www.largepick.com"><img src="clear.gif" height="200px" width="300px" /></a>
</div>