Last active
January 30, 2018 10:51
-
-
Save johnmccole/cb58b8aa58a91c863796fbc40b06fa81 to your computer and use it in GitHub Desktop.
Put an onerror event on images to load a fallback image if the original can't be found. Below is an example featured image.
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
<img src="<?php echo get_the_post_thumbnail_url(); ?>" alt="" onerror="this.onerror=null;this.src='<?= get_template_directory_uri(); ?>/dist/images/example.jpg';"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment