How to set priority order to Open Graph images for

2019-01-18 11:28发布

问题:

When pasting a link to a page within a comment, not directly as a wall post, Facebook defaults to choosing a thumbnail image, without users being able to choose the relevant thumbnail. Is it possible to set or determine priority for og:image tags on pages with multiple og:image tags? There doesn't seem to be any logical way to determine why FB is choosing any specific image. The image they are choosing isn't the first, or last image, by code order or alphabetized by name, and doesn't really follow any reasonable reason that I can figure out. Does anyone know how to set which image is chosen on comments?

I already know how to do this for wall posts, status updates, and sharing links, but you do not have the thumbnail chooser when posting links within comments, so being able to prioritize the order of multiple images would be ideal.

回答1:

I have just found out that Facebook will try to display best images (higher resolution) first. For example, if I have 3 meta tags in following order:

<meta content='http://mysite/low-res.jpg' property='og:image'>
<meta content='http://mysite/med-res.jpg' property='og:image'>
<meta content='http://mysite/hi-res.jpg'  property='og:image'>

then the order of displaying on Facebook dialog will be:

hi-res.jpg
med-res.jpg
low-res.jpg

I hope it will help.



回答2:

Actually, my experience is that the last tag (farthest down in the header) is given preference. On some of my sites I force the default by manually adding an og:image tag just before the tag.



回答3:

As per the instruction at ogp.me...

Arrays
If a tag can have multiple values, just put multiple versions of the same 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" />