Is there any way to set a default image that appears when I share my website on Facebook? I've noticed that Facebook usually fetches the first image from the site to use as a thumbnail.
6 Answers
You need to set the open graph image meta tag:
<meta property="og:image" content="http://example.com/logo.jpg">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1024">
<meta property="og:image:height" content="1024">
For more info check the docs
-
3
-
1I agree - still waiting for an answer to this. Just picks some random image on my site...– AndyJun 16, 2015 at 22:44
-
5@MindaugasJačionis according to linked-in all you need is the
og:image
tag, maybe the image you are seeing at the moment is cached, the caching will last up to 7 days. Jul 25, 2015 at 7:50 -
10@Rossco you'll need to clear facebook's cache of your website. Mar 22, 2016 at 22:54
-
7-1; it's not "the facebook image meta tag", it's a protocol supported by basically all social media sites. This post left me with the impression that this approach was Facebook-specific, but further research shows me that that is not the case. Sep 10, 2017 at 10:27
Set an og:image
in the <head>
of your HTML document like this:
<meta property="og:image" content="http://example.com/ogp.jpg" />
This is part of the Open Graph Protocol, respected by at least the following social media sites:
- Facebook (see https://developers.facebook.com/docs/sharing/webmasters/#images)
- Twitter (see https://dev.twitter.com/cards/getting-started#opengraph)
- LinkedIn (see https://developer.linkedin.com/docs/share-on-linkedin)
- Google+ (see https://developers.google.com/+/web/snippet/)
- Pinterest (see https://developers.pinterest.com/docs/rich-pins/reference/)
(... and probably plenty more besides.)
In addition to setting the tag above, you may also want to:
- Clear the social media platform's cached version of your page's image (e.g. by using the platform's developer tools), so that you can see the change reflected immediately. For example, you can do this for Facebook, at https://developers.facebook.com/tools/debug/
- Add additional "structured properties" to specify things like the image's width or height, using the syntax described at http://ogp.me/#structured. This is described as a "best practice" by Facebook at https://developers.facebook.com/docs/sharing/best-practices#images.
<meta property="og:image" content="http://example.com/lamb-full.jpg">
<meta property="og:image:type" content="image/jpeg">
<meta property="og:image:width" content="200">
<meta property="og:image:height" content="200">
Image size should be be at least 200px X 200px
-
Nice. What is the default for all sites that share the link? Is this just Facebook api? Apr 14, 2016 at 15:22
-
1@JoshYates1980 see stackoverflow.com/questions/10397510/… for more sites using open graph Sep 20, 2016 at 17:34
This my solution, it's work well:
<head>
<!--FACEBOOK-->
<meta property="og:image" content="https://www.website.com/logo.jpg">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1024">
<meta property="og:image:height" content="1024">
<meta property="og:type" content="website" />
<meta property="og:url" content="https://www.website.com/"/>
<meta property="og:title" content="Website title" />
<meta property="og:description" content="Website description." />
<head>
You can make test with Facebook Debug site.
Facebook's servers will 'scrape' your website looking for an image to use when people share it. If you want to specify which image to use, put this in the the <head></head>
section of your website:
<meta property="og:image" content="http://url-to-your-image.png">
Facebook may have cached a copy of the previous random image. To get facebook to fetch again:
<meta property="og:image" content="http://example.com/logo.jpg">
<meta name="twitter:image" content="http://example.com/logo.jpg" />
The above is all you need to update for all social link previews. To check what a preview looks like on a platform you can test your link using the tools below:
- Twitter https://cards-dev.twitter.com/validator
- Facebook/Instagram: https://developers.facebook.com/tools/debug
- LinkedIn: https://www.linkedin.com/post-inspector/