Skip to content

Instantly share code, notes, and snippets.

@johnmccole
Last active January 30, 2018 10:51
Show Gist options
  • Save johnmccole/cb58b8aa58a91c863796fbc40b06fa81 to your computer and use it in GitHub Desktop.
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.
<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