oneblueaugust Posted November 19, 2009 Share Posted November 19, 2009 I've been sitting here thinking of how to do this, and I'm completely stumped. It may not be possible, but I thought I'd ask, as there's tons of people here more knowledgeable than I am. Is there a way to write a script that will recognize a broken image link on a page? If so, is there a way to have that same script insert a stock image where the broken image was supposed to be (a "temporarily unavailable .gif" or something). This would be great to eliminate all those nasty red x's that I'm running into. Thanks for any help! Link to comment https://forums.phpfreaks.com/topic/182120-broken-image-link/ Share on other sites More sharing options...
abazoskib Posted November 19, 2009 Share Posted November 19, 2009 I've used the function is_file() before. If the picture is a file, then display it, else display default image. Link to comment https://forums.phpfreaks.com/topic/182120-broken-image-link/#findComment-960824 Share on other sites More sharing options...
ghostcoder Posted November 19, 2009 Share Posted November 19, 2009 Where are the images coming from and how are they getting populated into your HTML output? A broken image in HTML will look the same in HTML as a regular image. You could use php or javascript to test the images. But I would consider using .htaccess Just depends on your specific needs. Link to comment https://forums.phpfreaks.com/topic/182120-broken-image-link/#findComment-960830 Share on other sites More sharing options...
oneblueaugust Posted November 19, 2009 Author Share Posted November 19, 2009 The pictures are hotlinked from one of my other sites to my new one, so that they appear in my product listings. However, my new site has a bunch of products that my old one doesn't, so there's no pictures for them yet. So every other product has a red X populating the image slot, which sucks. Link to comment https://forums.phpfreaks.com/topic/182120-broken-image-link/#findComment-960837 Share on other sites More sharing options...
oneblueaugust Posted November 19, 2009 Author Share Posted November 19, 2009 I've used the function is_file() before. If the picture is a file, then display it, else display default image. Could you give me an example of a script like this that uses a hotlink for the file path? I'm clueless on this one... Link to comment https://forums.phpfreaks.com/topic/182120-broken-image-link/#findComment-960847 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.