{"id":215,"date":"2010-11-09T17:02:38","date_gmt":"2010-11-09T17:02:38","guid":{"rendered":"http:\/\/local.sandjam.co.uk\/?p=215"},"modified":"2018-08-03T14:00:42","modified_gmt":"2018-08-03T13:00:42","slug":"thumbnails-for-sharing-with-facebook","status":"publish","type":"post","link":"https:\/\/sandjam.co.uk\/sandjam\/2010\/11\/thumbnails-for-sharing-with-facebook\/","title":{"rendered":"Thumbnails for sharing with Facebook"},"content":{"rendered":"<p>Facebook&#8217;s integration which allows you to <a href=\" http:\/\/www.facebook.com\/sharer.php?u=http:\/\/local.sandjam.co.uk\/%2F&amp;amp;t=Sandjam\">post a page to Facebook<\/a> is really clever.<\/p>\n<p>A bit too clever in fact.<\/p>\n<p>The integration allows you to pass the url and title though to the sharing window. The sharing window then goes and take s a look at the page and selects the first few images it finds as likely candidates to use as thumbnail options.<\/p>\n<p>However there&#8217;s no functionality built in there to tell Facebook which images you&#8217;d like it to use.<\/p>\n<p>The <a href=\"http:\/\/developers.facebook.com\/search?q=Facebook_Share\/Specifying_Meta_Tags\">Facebook Developers documentation<\/a> suggests specifying the image in a meta tag<\/p>\n<pre class=\"qoate-code\">\r\n\r\n&lt;link rel=\"image_src\" href=\"http:\/\/media.clickonf5.org\/image\/logo.png\" \/&gt;\r\n\r\n<\/pre>\n<p>However it seems that the sharing window doesn&#8217;t actually pay any attention to this, and certainly doesn&#8217;t allow you to specify multiple images.<\/p>\n<p>I discovered this problem recently when I wanted to allow users to post a link to Facebook, but none of the images on the page were relevant to use as thumbnails.<\/p>\n<p>The solution I ended up using was to look at the the header information before the page loaded, and if the client requesting the page was the Facebook sharer page, I present just a page with the thumbnails I want to choose from. Then exist the script as the sharer doesn&#8217;t need to see any more of the page.<\/p>\n<pre class=\"qoate-code\">\r\nif (strstr($_SERVER['HTTP_USER_AGENT'], 'facebookexternalhit')) {\r\n?&gt;\r\n&lt;img src=\"http:\/\/mysite.com\/images\/facebookimage1.gif\" alt=\"\" \/&gt;\r\n&lt;img src=\"http:\/\/mysite.com\/images\/facebookimage2.gif\" alt=\"\" \/&gt;\r\n&lt;!--?php &lt;br ?--&gt; exit();\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Facebook&#8217;s integration which allows you to post a page to Facebook is really clever. A bit too clever in fact. The integration allows you to pass the url and title though to the sharing window. The sharing window then goes and take s a look at the page and selects the first few images it [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":622,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[4],"tags":[29,23],"class_list":["post-215","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-code","tag-facebook","tag-social-networking"],"acf":[],"_links":{"self":[{"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/posts\/215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/comments?post=215"}],"version-history":[{"count":8,"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/posts\/215\/revisions"}],"predecessor-version":[{"id":1106,"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/posts\/215\/revisions\/1106"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/media\/622"}],"wp:attachment":[{"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/media?parent=215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/categories?post=215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/tags?post=215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}