Skip to content

Instantly share code, notes, and snippets.

@rintoug
Created May 19, 2017 10:49
Show Gist options
  • Select an option

  • Save rintoug/2413065f1ed47e167e73a5bf3ea350a5 to your computer and use it in GitHub Desktop.

Select an option

Save rintoug/2413065f1ed47e167e73a5bf3ea350a5 to your computer and use it in GitHub Desktop.
Broken Image Handling
// Replace source
$('img').error(function(){
$(this).attr('src', 'no-image.png');
});
// Or, hide them
$("img").error(function(){
$(this).hide();
});
//if you want to one particualr image
$('.image-class').error(function(){
$(this).attr('src', 'no-image-hero.png');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment