Q:

Facebook dynamic og:image using PHP

I have a PHP site which needs multiple Facebook sharing images (og:image) and I'm parsing the URL and echoing the relevant filename into the og:image meta tag.
Viewing the page source shows it has the correct image, but Facebook debugger still scrapes the primary (home page) og:image.
<meta property="og:image" content="site.net/img/meta/<?php echo $og_image ?>.jpg">
Is there a way to have the shared og:image change relative to the full URL?
i.e. I share site.net/home and Facebook grabs one image while site.net/about would share another og:image.

A:

Yes, you can have a unique og:image (and any of the other Open Graph tags) on a per-page basis - just output different OG tags on those pages.
The most common reason these don't take is having an og:url page that points somewhere else (like the root at example.com), as Facebook will consider that the "canonical" URL for the page and fetch the OG tags from there instead of the current URL. You can set a unique og:url for each page, or you can leave it off entirely - if it's missing, Facebook will use the current URL as a fallback.

