Created
May 19, 2017 10:49
-
-
Save rintoug/2413065f1ed47e167e73a5bf3ea350a5 to your computer and use it in GitHub Desktop.
Broken Image Handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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