I know, you don't have broken images on your site, it's unprofessional and ugly. But sometimes you may be loading images that you don't control and you never know what's going on on the other server you're expecting to serve, but it may not feel up to the task.
One nice and simple strategy to deal with this uncertainty is to hide the images that fail to load. Browsers sent an "error" event when the worst happens and an image fails for whatever reason. Subscribe to this event using your favorite event-listener-attaching approach or library and hide the image.
Or with some ugly old-school inline event handler:
<img src="broken.png" onerror="this.style.display='none'" />
This entry was posted on Monday, February 16th, 2009 and is filed under images. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.