Sunday, April 20, 2014

Working with Broken Images on Your Site

Your website is only as good as your content. Images play an important part of overall content strategy of your site. And if your web site is dependent on third party data feeds, it may create ugly content for your site because of broken images. 

Instead of shown as broken, you can replace the broken images with a "missing image" graphic that exists on your site to give better visual feedback. This can be done using a small JavaScript snipplet as follows:

$("img").error(function(){
     $(this).attr('src', 'known_pic.jpg');
});


No comments: