当使用Facebook Sharer时,Facebook将为用户提供使用从源中提取的几个图像中的一个作为他们的链接预览的选项。如何选择这些图像,以及如何确保页面上的任何特定图像始终包含在此列表中?


当前回答

我无法让Facebook从特定的帖子中选择正确的图像,所以我做了这个页面上概述的事情:

https://webapps.stackexchange.com/questions/18468/adding-meta-tags-to-individual-blogger-posts

换句话说,是这样的:

<b:if cond='data:blog.url == "http://urlofyourpost.com"'>
  <meta content='http://urlofyourimage.png' property='og:image'/>
 </b:if>

基本上,你要硬编码一个if语句到你的网站的HTML中,让它改变元内容,不管你为那篇文章改变了什么。这是一个混乱的解决方案,但它有效。

其他回答

使用facebook feed对话框而不是共享对话框来显示自定义图像

例子:

https://www.facebook.com/dialog/feed?app_id=1389892087910588
&redirect_uri=https://scotch.io
&link=https://scotch.io
&picture=http://placekitten.com/500/500
&caption=This%20is%20the%20caption
&description=This%20is%20the%20description

把下面的标签放在头部:

<link rel="image_src" href="/path/to/your/image"/>

从http://www.facebook.com/share_partners.php

至于它在没有这个标记的情况下选择什么作为默认值,我不确定。

我有这个问题,并解决了它与手册84的建议。使用400x400px的图像效果很好,而我的小图像从未出现在共享器中。

请注意,Facebook推荐最小200px的正方形图像作为og:image标签:https://developers.facebook.com/docs/opengraph/howtos/maximizing-distribution-media-content/#tags

旧方法,不再有效:

<link rel="image_src" href="http://yoururl/yourimage"/>

报告新方法,也不奏效:

<meta property="og:image" content="http://yoururl/yourimage"/>

在我执行它的第一天,它随机地断断续续地工作,从那以后就再也没有工作过。

Facebook linter页面,一个检查你的页面的实用工具,报告一切都是正确的,并显示我选择的缩略图…只是share.php页面本身似乎不能正常工作。肯定是Facebook的一个bug,他们显然不愿意修复,因为我在他们的系统中看到的关于这个问题的每个bug报告都说已经解决或修复了。

截至2013年,如果你使用facebook.com/sharer.php (PHP),你可以简单地创建任何按钮/链接:

<a class="btn" target="_blank" href="http://www.facebook.com/sharer.php?s=100&amp;p[title]=<?php echo urlencode(YOUR_TITLE);?>&amp;p[summary]=<?php echo urlencode(YOUR_PAGE_DESCRIPTION) ?>&amp;p[url]=<?php echo urlencode(YOUR_PAGE_URL); ?>&amp;p[images][0]=<?php echo urlencode(YOUR_LINK_THUMBNAIL); ?>">share on facebook</a>

链路查询参数:

p[title] = Define a page title
p[summary] = An URL description, most likely describing the contents of the page
p[url] = The absolute URL for the page you're sharing 
p[images][0] = The URL of the thumbnail image to be used as post thumbnail on facebook

这很简单:你不需要任何js或其他设置。只是一个HTML原始链接。 以任何您想要的方式样式A标记。