78

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.

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
paz
  • 1,155
  • 2
  • 11
  • 13

6 Answers6

108

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

Patsy Issa
  • 11,113
  • 4
  • 55
  • 74
  • 3
    I used this way and it still picks a random image from my site? – Rossco May 28 '15 at 14:40
  • 1
    I agree - still waiting for an answer to this. Just picks some random image on my site... – Andy Jun 16 '15 at 22:44
  • By random do you mean every other time it changes or is it the same picture but not the one you set in the meta tags? – Patsy Issa Jun 17 '15 at 06:15
  • For facebook this helped, however in linkedin if I try to add website as a link to my profile experiences it shows first img tag source image. :) – Mindaugas Jul 24 '15 at 17:52
  • 5
    @MindaugasJačionis according to [linked-in](https://developer.linkedin.com/docs/share-on-linkedin) 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. – Patsy Issa Jul 25 '15 at 07:50
  • @MindaugasJačionis I've had similar problems with caching too, like Kitler said. Try clearing your browser cache and see what happens – Daniel Jul 26 '15 at 04:49
  • 10
    @Rossco you'll need to [clear facebook's cache](https://developers.facebook.com/tools/debug/) of your website. – full_prog_full Mar 22 '16 at 22:54
  • 7
    -1; it's not *"the facebook image meta tag"*, it's a protocol supported by [basically all social media sites](https://stackoverflow.com/a/29067915/1709587). This post left me with the impression that this approach was Facebook-specific, but further research shows me that that is not the case. – Mark Amery Sep 10 '17 at 10:27
  • @MarkAmery you could follow your bio's advice and improve a 4 year old answer :) – Patsy Issa Sep 10 '17 at 16:22
15

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:

(... and probably plenty more besides.)

In addition to setting the tag above, you may also want to:

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
14
<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

josliber
  • 43,891
  • 12
  • 98
  • 133
Raina Vinod
  • 141
  • 1
  • 3
11

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.

Sébastien REMY
  • 2,399
  • 21
  • 39
8

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:

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
full_prog_full
  • 1,139
  • 10
  • 17
0
<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: