I have a web application build on PHP that (does some processing and) displays images hosted on external servers. Some of these images (i.e. from Flickr) when they are deleted, leave a redirect behind that points to a "Missing Image" gif or something equivalent.
By using the get_headers()
function in php on each image, I was able to check server-side if an image was deleted or not (for example, by checking if the Content-Type
was image/gif
instead of image/jpg
, on Flickr images).
The problem is that each page returns 20-100 images on average (sometimes even more), and get_headers()
requires on average 0.3-0.5s for each image, thus making the wait time for the user too long.
I was wondering if this check could be done client-side, using javascript. The user will be waiting for the images to load (as with any page), I will be checking the images if they are valid, and set display property to none on the missing ones.