{"id":3219,"date":"2011-06-16T07:00:45","date_gmt":"2011-06-16T14:00:45","guid":{"rendered":"http:\/\/restlesspilgrim.net\/blog\/?p=3219"},"modified":"2015-03-19T14:06:22","modified_gmt":"2015-03-19T21:06:22","slug":"thumbnails-in-facebook","status":"publish","type":"post","link":"https:\/\/restlesspilgrim.net\/blog\/2011\/06\/16\/thumbnails-in-facebook\/","title":{"rendered":"Thumbnails in Facebook"},"content":{"rendered":"<p><em><span style=\"color: #888888\">As you know, I write my blog entries a while before they actually get posted. Since writing this entry I have found better ways of achieving the desired effect using WordPress Plug-ins. However, I decided to post it anyway since I think it&#8217;s still quite a neat exercise in tricking computers to do what you want&#8230; \ud83d\ude42<\/span><\/em><\/p>\n<p>Today is purely a technical blog for my fellow bloggers.<\/p>\n<p>I&#8217;ve had a problem that has been bugging me for some time. \u00a0If I post a link to a blog entry on Facebook which\u00a0contains no images, then no thumbnail image is displayed:<\/p>\n<p><a href=\"http:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/without_thumbnail.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3222 aligncenter\" src=\"http:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/without_thumbnail.png\" alt=\"\" width=\"510\" height=\"261\" srcset=\"https:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/without_thumbnail.png 729w, https:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/without_thumbnail-300x153.png 300w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<p>I&#8217;ve noticed that when I don&#8217;t have a thumbnail image, the web traffic generated by people visiting my blog from Facebook seriously declines.<\/p>\n<p>This is particularly problematic for my &#8220;Friday Frivolity&#8221; posts. Since these entries are usually just a few lines of text and a YouTube video, they have no thumbnails when shared on Facebook.<\/p>\n<p>Tonight, I found a fairly simple solution to this problem&#8230;<\/p>\n<p><!--more--><\/p>\n<h2>Step 1: Setup A CSS Class<\/h2>\n<p>First of all, you have to setup a &#8220;CSS style&#8221; in your WordPress Theme. This is done by logging into your Dashboard and clicking on <span style=\"color: #000000\">&#8220;Appearance&#8221;<\/span> and then <span style=\"color: #000000\">&#8220;Editor&#8221;<\/span>. A large text area is then displayed. Add the following line to the text:<\/p>\n<p style=\"padding-left: 30px\">img.facebook { display: none; }<\/p>\n<p>&#8230;and then click the &#8220;Update File&#8221; button:<\/p>\n<p><a href=\"http:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/css.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-3223 aligncenter\" src=\"http:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/css-1024x543.png\" alt=\"\" width=\"491\" height=\"261\" srcset=\"https:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/css-1024x543.png 1024w, https:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/css-300x159.png 300w, https:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/css.png 1300w\" sizes=\"auto, (max-width: 491px) 100vw, 491px\" \/><\/a><\/p>\n<p>You may need to refresh you cache at this point to make sure that your browser picks up the newly-generated CSS file (this can be a little bit fiddly and varies from browser to browser &#8211; <a href=\"http:\/\/restlesspilgrim.net\/blog\/contact\/\">email me<\/a> if you have problems).<\/p>\n<p>You then write your blog entry as usual.<\/p>\n<p>&nbsp;<\/p>\n<h2>Step 2: Insert the Image<\/h2>\n<p>Next, you want to create the image which will be used by Facebook as a thumbnail. I usually take a screenshot of the running video. I then resize it to the dimensions 90&#215;90 pixels. Now insert this image into the blog post as you would any other image.<\/p>\n<p>If you published the post now, the image would be visible. So, switch to the &#8220;HTML&#8221; view in the WordPress editor and add the\u00a0&#8220;facebook&#8221;\u00a0class to the image you just inserted:<\/p>\n<p style=\"padding-left: 30px\"><span style=\"color: #000000\">&lt;a img=&#8221;http:\/\/myblog.com\/thumbnail.png&#8221; class=&#8221;facebook&#8221;\/&gt;<\/span><\/p>\n<p style=\"text-align: left\"><a href=\"http:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/editor.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3224 aligncenter\" src=\"http:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/editor.png\" alt=\"\" width=\"470\" height=\"335\" srcset=\"https:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/editor.png 746w, https:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/editor-300x213.png 300w\" sizes=\"auto, (max-width: 470px) 100vw, 470px\" \/><\/a>Adding the &#8220;facebook&#8221; class causes the image element to be hidden when the post is viewed by your readers.\u00a0However, when <em>Facebook<\/em> looks for a sample thumbnail, it doesn&#8217;t check the CSS&#8230; \ud83d\ude42<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/with_thumbnail.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3225 aligncenter\" src=\"http:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/with_thumbnail.png\" alt=\"\" width=\"459\" height=\"235\" srcset=\"https:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/with_thumbnail.png 729w, https:\/\/restlesspilgrim.net\/blog\/wp-content\/uploads\/2011\/06\/with_thumbnail-300x153.png 300w\" sizes=\"auto, (max-width: 459px) 100vw, 459px\" \/><\/a><\/p>\n<p style=\"text-align: left\">Unfortunately, neither does the Visual Editor, so it&#8217;ll still appear there \ud83d\ude41<\/p>\n<p style=\"text-align: left\">You can&#8217;t win them all&#8230; \ud83d\ude09<\/p>\n<p><em><span style=\"color: #ff0000\">UPDATE: Since writing this (most posts get finished a week or two before they actually get posted), I think there is an easier way of doing this using plug-ins. Oh well, it was still a fun challenge&#8230; \ud83d\ude42<\/span><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As you know, I write my blog entries a while before they actually get posted. Since writing this entry I have found better ways of achieving the desired effect using WordPress Plug-ins. However, I decided to post it anyway since I think it&#8217;s still quite a neat exercise in tricking computers to do what you want&#8230; \ud83d\ude42 Today is purely<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[17],"tags":[265,62,2969,264,266],"class_list":["post-3219","post","type-post","status-publish","format-standard","hentry","category-faith","tag-css","tag-facebook","tag-featured","tag-thumbnails","tag-wordpress"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/restlesspilgrim.net\/blog\/wp-json\/wp\/v2\/posts\/3219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/restlesspilgrim.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/restlesspilgrim.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/restlesspilgrim.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/restlesspilgrim.net\/blog\/wp-json\/wp\/v2\/comments?post=3219"}],"version-history":[{"count":26,"href":"https:\/\/restlesspilgrim.net\/blog\/wp-json\/wp\/v2\/posts\/3219\/revisions"}],"predecessor-version":[{"id":56248,"href":"https:\/\/restlesspilgrim.net\/blog\/wp-json\/wp\/v2\/posts\/3219\/revisions\/56248"}],"wp:attachment":[{"href":"https:\/\/restlesspilgrim.net\/blog\/wp-json\/wp\/v2\/media?parent=3219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/restlesspilgrim.net\/blog\/wp-json\/wp\/v2\/categories?post=3219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/restlesspilgrim.net\/blog\/wp-json\/wp\/v2\/tags?post=3219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}