Search This Blog

Friday, November 18, 2016

Getting FB to Show the Right Photo in WordPress

Sharing a drinkFacebook used to allow one to cycle through photos from a shared link, giving the poster control over which imaged showed, or allowed one to not show a photo at all but keep the graphic link. For some unexplained reason, this feature was lost in an update some time ago. Now a poster has absolutely no control over the selection of  a site's photo in their link, usually pulling one from an unrelated article. Very frustrating.

Today I finally did some research and found one way to re-activate that feature. Figuring others would want this information, I decided to post it here and share it on Facebook.

This works on my WordPress site, this blog (version 3.0.3--yes, I need to update). The concept should work on other sites if you can add to the webpage's meta data. What needs to be added is the following metadata link in the webpage's <head> area: <meta property="og:image" content="image weblink here" /> For WordPress there is an easy way to do this for an individual post.

Once logged in to your admin page on the blog, and on the "add new post" or "edit a post" page, you'll see under the post entry window a section labeled "Custom Fields." Click the "Enter new" link. In the "name field," enter: og:image. In the content field, enter the full web-link to your image. You can find that address if you have inserted it into your post by right-clicking the image in the post entry field and select "Copy image address" from the menu. Then paste it into the content field of your new entry.

Once published, share on Facebook as usual. You should now see the old arrows allowing you to cycle through available images, one which should be your post photo.

You're welcome!

Update #1:


Apparently Facebook's photo memory is limited when it allows you to choose a photo. This method does allow the option (currently, they could change that at any time) to select multiple photos from the referenced site, but there is no guarantee that the post's photo will be included among them. In the case of this post, the photo above wasn't in the choices I had, so I selected my mug shot. Better than a totally unrelated photo like the covers of one of my books, but not what I had hoped. We'll see how it goes with future posts.

Update #2:


After some more research, I've discovered that Facebook has a sub-site that handles this, and though the above custom fields seems to indicate it will add that text into the metadata, apparently it doesn't upon reviewing the source code, even though it seems to force Facebook to allow a choice of images instead of forcing you to take what it gives you. No, the real solution is to install a plug-in that makes it easy to output that data automatically, or add in the needed code in the theme's function.php file to automatically set the featured image to be output as the image Facebook picks up.

Being geeky, I fiddled with the code of the file, and after some failed attempts, got it to work. You, however, may want to take the simpler route by installing one of two plug-ins that will do the job. I've not tried either of those so I can't tell you how well or easy they are to work with.

Rather than regurgitating that article with the information on how to do that here, I'll point you to the site that I found to be the most help on this topic: How to Add Facebook Open Graph Meta Data in WordPress Themes

The only note on this is to make sure your original file is bigger than 200px x 200px, but not more than 8 MB. Otherwise you'll get errors from Facebook.

There you go! Now I should have the right image post to Facebook each time.

No comments:

Post a Comment