homepage Welcome to WebmasterWorld Guest from 54.166.113.249
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Show a picture when another picture doens't load
turbohost

10+ Year Member



 
Msg#: 3354767 posted 7:11 pm on May 30, 2007 (gmt 0)

Hi,

Is it possible to show another picture if a picture doesn't load on your site? E.g. I show picture A from website A on my website (ok, ok, it's hotlinking :-) ). If picture A doesn't load, I want to show picture B (and no alternative text).

Turbo

 

encyclo

WebmasterWorld Senior Member encyclo us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3354767 posted 4:59 pm on May 31, 2007 (gmt 0)

It isn't possible with HTML as such, but it may well be possible using mod_rewrite (assuming your server is running Apache) to rewrite non-existent image URLs to a specific file. It is similar in many ways to an anti-hotlinking script, but the conditions for the rewrite would be different.

I'm moving this thread over to our Apache forum to see if you can get a more definitive answer from the rewrite experts. :)

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3354767 posted 12:22 am on Jun 1, 2007 (gmt 0)

You'd have to 'wrap' the image in a script, use the script to GET the image, and then substitute something else if the GET was unsuccessful. Of course, this means that all image requests would come from your server instead of the client, making it trivially easy to track you down...

Doing this to grab images from any site I administrate wouldn't work, at least not for long...

With respect, I'd suggest finding a better way to do business.

Jim

Achernar

5+ Year Member



 
Msg#: 3354767 posted 12:23 am on Jun 1, 2007 (gmt 0)

You can do it with javascript.

How many images do you have to check on a single page? Are they always the same one?
Are you pages dynamic or static? (.asp/.php vs .html)

turbohost

10+ Year Member



 
Msg#: 3354767 posted 10:01 am on Jun 2, 2007 (gmt 0)

Hi Guys and thanks for all the responses. I think I have to elaborate a little bit more. The images are always the same image (i.e. a green bullet) and I provide this image to the other webmasters. The other webmasters agree to put this image in the home directory of their website. I open their image via img src on my webpage. If their image doesn't load it means that their website is down or filtered. If the site is down I want to show another image instead of the alternate text.

Achernar

5+ Year Member



 
Msg#: 3354767 posted 12:28 pm on Jun 3, 2007 (gmt 0)

A simple solution (if the replacement image is always the same) could look like this:

<html> 
<script>
function down(e) {
e.src='url of image replacement';
}
</script>
<body>
<img src="http://none.dev.null/image.gif" onerror="down(this)">
<img src="http://another.dev.null/image.gif" onerror="down(this)">
<img src="http://last.dev.null/image.gif" onerror="down(this)">
</body>
</html>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved