I have recently shifted my site to another host by exporting the data. And I don’t have the original data. After shifting I knew the images were not properly exported and I didn’t get all the images. so I want to display my logo in those files where images source were unknown.
say my main image is original.jpg and if it does not display then i want to display missing.jpg which is inside images folder of my theme.
Syntax can be as follow
<img src="original.jpg" onError="this.onerror=null;this.src='<?php echo get_bloginfo('template_url');?>/images/missing.jpg';" />
If you use for thumbnail image you can use this
<img src="<?php echo get_the_post_thumbnail_url(); ?>" onError="this.onerror=null;this.src='<?php echo get_bloginfo('template_url');?>/images/themeimage.png';"/>