This PHP code, written by one of the Jetpack plugin Developers, enables you to display a fallback image which is shared to the social accounts you configure in the plugin settings.
Simply change the URL in the code to your fallback image which will be used if you don’t add a featured image or your post doesn’t contain any images.
Note: Different social networks may impose a size limit on images so i suggest you keep them at least 200px x 200px.
Testing On Local Host
If you want to test out any code using Jetpack on your local installation of WordPress, you can choose from 2 options which enable you to activate the plugin locally.
Add this line to a plugin or in your child themes functions file.
add_filter( 'jetpack_development_mode', '__return_true' );
Or add this line to your wp-config.php file.
define ('JETPACK_DEV_DEBUG', true);
Other Options
A more complete solution would be to add a fallback image for featured images. The solution for this and the methods available vary per theme.
Image from Images Folder
Use image from child themes images folder as fallback for featured image when none added:
Leave a Reply