Igor's Blog
Programming, DIY, Games, Hacks, and Tech

When I first wrote about ingegreating with Facebook I shared an example on how to share a post link and provide additional data like a picture to use as a thumbnail. This used to tell Facebook that the provided picture should be shown as the link preview, this no longer works. You can still submit the 'picture' property as a URL but it will be ignored. This behaviour is described in the Graph API version 2.10. Fortunately there is a way to control which image Facebook will use.

First lets understand why this change has been made. Facebook had this to say about the topic.
As part of our continuing efforts to stop the spread of misinformation and false news on our platform, earlier this year at F8 we announced an important change to our Graph API: Graph API version 2.9 includes a 90 day deprecation of the ability to edit previews attached to link posts.

So it's all about fake news. Although I understand Facebook's position on this, I do not agree completely with this change. Lets look at what you can do now to control which image appears as a link preview thumbnail...

As Facebook said, the Open Graph meta tags are the currently supported way to modify link previews. Fortunately this is easy to add to a CMS or Blog system. It only took me a couple of hours to have a full end-to-end solution in my Blog's code working.

The trick is to implement tags like this in the <header> of your generated HTML page...
 OpenGraph image tags
<meta property="og:image" content="https://www.mydomain/myimage.jpg" />
<meta property="og:image:type" content="image/jpeg" />
<meta property="og:image:width" content="300" />
<meta property="og:image:height" content="300" />

The og:image tag is the one that is required, others are optional but I would recommend using them. This works the same way as back when the 'picture' property was supported with the API. Simply put the URL of the image into the content attribute and you're done. The image here needs to meet some guidelines e.g. it has be be less than 8Mb in size for Facebook to download it.

The og:image:type tag specifies the MIME type of the image. The og:image:width and og:image:height provide the width and height of the image (in pixels) respectively.

A PHP example on posting links is covered in Facebook's documentation here. Don't forget to use the URL Debugger after making your changes to ensure Facebook is behaving as you were expecting.


Please leave your comments or feedback below!
comments powered by Disqus
Other posts you may like...

Recent Blog Posts

How to enable the full stack trace in Maven's Surefire plugin for JUnit testing

Twelve elements of the Burst Mining Pool interface explained

TPG FTTB settings for the Billion BiPAC 8700AXL 1600 modem router

Protecting old Atari Lynx game boxes with snug fit plastic sleeves

How to fix SoapUI javax.net.ssl.SSLHandshakeException calling WebLogic 12.2 web services on Java 8

Woolworths (WOW) shares disappeared from Computer Share Investor Centre

Connecting the Dell UltraSharp U3415W monitor to a MacBookPro via USB-C

How to add/change PHP versions appearing in MAMP preferences

Fix the ORA-00904: ORA_ROWSCN: invalid identifier error in SQLDeveloper with a few easy steps

G Suite Gmail is broken on Safari due to new Google Content Security Policy settings

Recent Galleries

Protecting old Atari Lynx game boxes with snug fit plastic sleeves

Monument Valley 2 is released and does not disappoint

Space Food - Chocolate Ice Cream with Chocolate Chips

Legeod Star Wars AT-DP kit

DIY spare parts computer build with a RAIDMAX Anura case

Fake 'Lepin' brand Lego packaging

Hardwood garden bench with clear resin void filler

Fixing a 3D printer extruder that stopped heating up

Easily increase disk space in a Lenovo Ideapad 100S 14" laptop with an M.2 SSD

Making a multi-piece 3D printed solder spool holder stand

My Other Web Sites

Igor and Elise's Travels
Riverside Expressway Cam
300 George St Blogumentary

My Online Tools

UUID to OID Converter
Guru JSON-RPC Tester
Extrudifier Object Designer
Travel ┬ÁBlog

Blogs and Friends

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity
Don't forget to
my Facebook page for more great articles!
Don't show this again