Add a default image to Jetpack if no image present in a post

Here is a code snippet to add a default image to Jetpack if no image present in our post and we wish that image to be used by Jetpack when it publicizes our post.

When we publish a new post, Jetpack by WordPress automatically shares the post on social networks if we have enabled sharing module provided by it.

Jetpack crawls the post and looks for images that can be used when sharing that post on Facebook, on Twitter. It starts by looking for a featured image. If that is not define then slideshows and galleries are looked and at last for single images we may have inserted in our post. Even Jetpack can use an image that is hosted on another site and  inserted to post.

You can add this code snippet to your theme’s functions.php file, if you may not have added any image to your post. In this way, your readers will see a default image when sharing that post on Facebook or Twitter:

Replace ‘YOUR_LOGO_IMG_URL_HERE’ with your actual image url to  add a default image to Jetpack. Please be aware that your image should be larger than 200 x 200px as per Facebook requirement otherwise your image will be ignored.

You Might Interested In

Leave a Reply

Enclose a code block like: <pre><code>Your Code Snippet</code></pre>.