I have a blog with some posts, and each post has a embedded Facebook like button. Pressing the button opens a dialog so my visitors can share the post on Facebook with a comment.
When sharing, however, the image selected by Facebook is a generic mail icon and not the post thumbnail.
How can I control the image that is used when sharing?
The image that is used for sharing is taken from a chunk of code in the header of your site that will look something like this:
Typically it links to the screenshot of your site in the theme. If you removed the code from the header of the file and on single.php put it inside the loop and called your post thumbnail image into the href element I believe it would work. So it would look something like:
This would mean that if you have like buttons on pages that list multiple posts you probably won’t have an image. If you included some conditional code that removed it only on single.php then you would have the normal image on any page with multiple posts and an like button and the post thumbnail when the single.php template is being used. So the header code would be:
Then you’d still use the code to include the post thumbnail in single.php.
Facebook now uses opengraph protocol. You can add images using :
Add this line to your page header.
Alternatively you can use my plugin to do this automatically.
It just does this job and no settings are needed.
http://shailan.com/wordpress/plugins/facebook-meta-tags-plugin/
You need to use the Facebook Open Graph Protocol. I’m not sure why the Accepted answer isn’t one of the many OG: related answers (which I’ve voted up) but it is wrong.
http://developers.facebook.com/docs/opengraph/
You can customize many things including title, image, description, category, last update etc… if you use Open Graph. If you use these other half-solutions you are missing the whole picture.
If I didn’t follow OG Protocol for all the FB work I do, I’d get fired.
If you do the following:
You’ll find that WordPress outputs the the html required to display the image, not just the SRC which is what you really want.
Doing something like:
gets you the URL only. It’s probably the long way and can probably but shortened, but it definitely fixes the problem.
Hope this puts you on the right track.
Matt.
Make sure you lint your URL here if the specified image is not appearing properly:
http://developers.facebook.com/tools/lint/
If you would like to use the first image of your post as the thumbnail with a fallback to something like your logo, try my plugin – http://wordpress.org/extend/plugins/facebook-like-thumbnail/
Explanation for adding the fallback logo image is at http://blog.ashfame.com/?p=888
This method works for “like”:s but later on if you want to share a link in ur log(For example.) this picture is autoselected.
Without this meta tag you are able to select from all the images on the linked site.
Anyone know any way to keep the static “like” image but still make you choose an image when sharing a url?