Facebook multiple og:image tags - Which is Default

2019-02-04 05:48发布

问题:

My web site specifies multiple og:image tags, and I'd like to control which one is the default. Does it have something to do with the order in which they're specified?

Right now the images are appearing in the link post selector in the order #3, #1, #2 (#3 being the default), which seems quite unusual.

Thanks for any insights you might have.

回答1:

I was curious, so I scoured around trying to find an answer to the "default image" question. This was literally the only link I could find where any research had been done on the matter, where they suggest that higher-res images will receive top priority:

How to set priority order to Open Graph images for links that are inserted in comments. (Not sharing or wall posts.)

However, based on that example, FB might just be picking the last og:image tag on the list. A previous SO answer came to a similar conclusion:

Facebook sharer.php, how to have multiple og:image tags?

I apologize if I answered your question with more questions, but maybe this will give you a good lead, at least. If you add more tags and FB consistently picks the last one, you'll hopefully have your solution. :)



回答2:

From the Open Graph Protocol:

Arrays

If a tag can have multiple values, just put multiple versions of the same <meta> tag on your page. The first tag (from top to bottom) is given preference during conflicts.

<meta property="og:image" content="http://example.com/rock.jpg" />

<meta property="og:image" content="http://example.com/rock2.jpg" />

When I test this in the Facebook Sharing Debugger, I only see the first image previewed. But when I begin a share of my URL on Facebook itself, I see the first image previewed along with the left/right buttons for choosing the second image, as below:



回答3:

Here's what works for me. In the header of your page, insert this code

<meta property="og:image" content="http://yourdomain.com/yourimage.png" />

This gives the image I choose priority. It should be one of the highest resolution photos on your page.

Then, force Facebook to clear it's cache with this. This debugger tool will also show you which image Facebook is favouring.