If I post a link to a website on Facebook, an image is rendered beside it.
How does facebook decide which image to load from my site?
Is it possible to control what image is displayed? Can I set this somewhere, maybe in the meta tags?
If I post a link to a website on Facebook, an image is rendered beside it.
How does facebook decide which image to load from my site?
Is it possible to control what image is displayed? Can I set this somewhere, maybe in the meta tags?
Facebook (and other companies after FB proposed this standard) uses the Open Graph Protocol to gather information from your page.
If you provide the relevant meta tags within your <head>
tag, e.g.:
og:title
- The document's titleog:type
- The document's type og:image
- An image URL to represent your document (this is the bit you are interested in)og:url
- The canonical URL the document.For the image meta tag:
<meta property="og:image" content="https://example.com/pony.jpg" />
It will use the information in these tags to populate the post. Other online and messaging services and will also use this information if present.
If the OGP meta tags are absent, FB (and other services) will crawl the URL and try determine as best as they can which image should be used instead.