Social Networks

Facebook Shared Link Thumbnail – How to Make it Work

Facebook Shared link thumbnail
Written by Wamiq Ali

Often a times we have seen that while sharing links to the Facebook we are not able to get the thumbnail for the shared link in the previews window of our Facebook page, profile or group. To make this Facebook shared link thumbnail work in the preview pane we will need to ad some Facebook open graph tags in our site or the CMS which we use to generate our content. I am writing this post in a generalized manner without pointing at any CMS so if you are intelligent enough then you will surely get that this post is a universal one and can be used for all the CMS or even static HTML sites.

Be Sure to Add Facebook Open Graph Tags to let Facebook shared link thumbnail work at Facebook:

Whenever you write something which has a thumbnail then you need to add some open graph tags used for Facebook to let any specific image appear as the thumbnail for shared post while posting link to Facebook.

You need to add the following code to the site with the path of the image to be shown as the thumbnail in the link preview which I said like Facebook shared image thumbail to work properly.

<meta property="og:image" content="Your Image Path Here" />

This above code needed to be added in the <head> section of your static or dynamic pages.

Easiest Solution to be used when you are at WordPress t0 make Facebook shared link thumbnail show up:

I am pretty sure that all the readers of this post use featured image for their blog posts at the wordpress. In the case if you really use then happily you can solve this problem really quick, Be sure to add this code to your head section in the header.php of you template to make the featured image show as thumbnail while sharing the blog links to Facebook.

<?php is_single(); { ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<meta property="og:image" content="<?php echo $image[0]; ?>" />
<?php } ?>

The code above in the head section will tell the WordPress that if it is single then use the Featured image of post as the image for Facebook shared link thumbnail.

About the author

Wamiq Ali

Programmer, Blogger and an Entrepreneur trying to make this web a better place by making others learn for free.

Leave a Comment