FB Share Image Changer (2017)


Facebook uses the Open Graph Meta Tags to determine the image and text for sharing.

What if you want to share a specific link but you want to use a different image and description?

Facebook preloads the image and the description from the shared link:

The shown script identifies the user agent from Facebook und returns different OG data. All other user agents are redirected to the destination link.

The important lines are:

  • og:image (line #23) with your favored image
  • og:description (line #20) with the new description
  • the destination link (line #38)

Disclaimer: This script did work in early 2017. Maybe Facebook changed the behavior.