Created
April 16, 2015 12:44
-
-
Save ubergoober/c092a31e437a8eb7a832 to your computer and use it in GitHub Desktop.
Cleanly replace missing images in web page
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
| /* | |
| The below img error snippet will instantly hide any broken image placeholders | |
| although it appears there's extra steps happening here (hidding and unhiding), | |
| The reason is that the split second delay of reloading a new placeholder image | |
| can cause the ugly missing image placeholder to flash if we don't hide it instantly on err. | |
| */ | |
| $("img").error(function () { | |
| $(this).css({visibility:"hidden"}); | |
| $(this).attr({src:'/images/theme/no_logo_placeholder.png'}); | |
| $(this).css({visibility:"visible"}); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment