View Full Version : Hide IMG placeholder
larrywade
01-17-2008, 08:31 PM
HTML question - In Firefox, when you have an IMG with a placeholder of ALT="", then just a blank shows up on your web page. But in Internet Explorer, it displays a blank outlined image. Is there a way to code around this in HTML?
Tom E.
01-17-2008, 08:49 PM
Do you mean an img tag that doesn't have an associated image, like this?<img alt="">
If so, you could comment it out until you're ready to set the src attribute:<!-- <img alt=""> -->
larrywade
01-17-2008, 09:06 PM
Here is my code - <img src="../Gallery/pic1.jpg" width="200" border="0" alt="">
When there is no pic1.jpg then in Firefox nothing is displayed (which is what I want). But in Internet Explorer it displays an image placeholder with an outlined blank image.
Tom E.
01-17-2008, 09:18 PM
I don't know of any way for a web page to keep IE from displaying the "broken img" icon.
Are you trying use a generic page to display a number of images in a directory, and just have empty space if all the images aren't there?
If so, it's better to generate the page with a script which only ouputs an img tag if the corresponding jpg file exists.
You could also create a dummy jpg image that is the same color as your background, and have the unused <img> tags point to that.
larrywade
01-17-2008, 10:30 PM
Yes, I am trying to have a generic page like:
<img src="../Gallery/pic1.jpg" width="200" border="0" alt="">
<img src="../Gallery/pic2.jpg" width="200" border="0" alt="">
<img src="../Gallery/pic3.jpg" width="200" border="0" alt="">...
So for example if pic3 and up are not there, there is nothing displayed except pic1 and pic2. I don't think having an image holder would work because I am specifying a width of 200 so I think it would still make the border.
You could use .htaccess in the Gallery directory with a ErrorDocument 404 http://yourdomain.com/Gallery/clear.gif
and upload clear.gif as a 1 pixel clear gif image
Tom E.
01-18-2008, 08:30 AM
Using ErrorDocument for the placeholder images - what a cool idea.
I don't think having an image holder would work because I am specifying a width of 200 so I think it would still make the border.
There wouldn't be a border, since you have border="0" in the tag.
Also, there's gotta be a free script somewhere that you can just plop in a directory and it will make a nice gallery of all the images in that directory.
Arthur
01-18-2008, 08:41 AM
Why not use some simple scripting, something along these lines (in PHP); <?php
if (file_exists("../Gallery/pic1.jpg")) {
print '<img src="../Gallery/pic1.jpg" width="200" border="0" alt="">';
}
if (file_exists("../Gallery/pic2.jpg")) {
print '<img src="../Gallery/pic2.jpg" width="200" border="0" alt="">';
}
if (file_exists("../Gallery/pic3.jpg")) {
print '<img src="../Gallery/pic3.jpg" width="200" border="0" alt="">';
}
?>
You could make it a for loop for more images.
-Arthur
vBulletin® v3.6.8, Copyright ©2000-2012, Jelsoft Enterprises Ltd.