View Full Version : Load one image if another doesn't load...does this exist?
Gnome_101
10-27-2004, 07:09 AM
Here's what I am looking for. A way in HTML to have a secondary image to load if a first image does not load. Is there code to do this already?
Would a low src work?
If not then I propose a new addition to the scr tag in HTML. W00t!
dilligaf
10-27-2004, 08:43 AM
I can't imagine that there would be. In ASP/PHP you can call for an alternate image if the primary image doesn't exist but even then it wouldn't have anything to do with loading as that is a function of the users machine, connection etc.
Gnome_101
10-27-2004, 09:55 AM
hmm...
I want to re-rwrite the tag for the src then hehe,...
<img src="<url of primary>","<url of secondary(only if first doesn't load)>">
The hard part would be making the browser resolve that the first image is null, then to load the second.
Hmmm....perhaps I will talk to the Mozilla people.
Thanks dilligaf - I didn't know there were alternate functions for this purpose in Asp/PHP.
I will look into those optoins as well!
Gnome_101
06-06-2005, 08:32 AM
after learning php, I used the following code to load a seoncdary image if the first one fails to load, or does not exist.
$img = "../pics/thumbs/{$row['part_numbers']}.jpg";
$image_width = getimagesize($img);
if(!getimagesize($img)) // if image does not exist, replace with secondary
{
echo "<td width=\"15%\"><img src=\"slotcars/logos/fly_logo.jpg\"></img>";
}
else{ // everything is ok, load original image
echo "<td width=\"15%\"><img src=\"../pics/thumbs/{$row['part_numbers']}.jpg\"></img>";
}
jlknauff
06-08-2005, 08:40 PM
I thought there was (or something similar) but don't remember what it was off the top of my head. Let me know if you still need an answer.
Gnome_101
06-09-2005, 05:17 PM
No thanks,
The code I posted above does what I need. It works like a charm, and I thought perhaps I'd share it with others!
Thanks though!
Warning! If you have a limit on the site of your scripts files (where php errors are thrown), please be mindful that everytime it need to do the logo, it will throw and error
vBulletin v3.0.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.