简体   繁体   English

Facebook如何提取链接的正确缩略图?

[英]How facebook extracts the right thumbnail of a link?

I'm wondering how facebook extracts the right picture of the article from a link? 我想知道Facebook如何从链接中提取文章的正确图片? they ignore any icons, ads images, or other not related images, & they gives you the right image? 他们会忽略任何图标,广告图片或其他不相关的图片,并为您提供正确的图片?

What technique/method they use? 他们使用什么技术/方法? because i've tried to extract all images using a php regex but how to find the right one? 因为我尝试使用php正则表达式提取所有图像,但是如何找到合适的图像呢?

Thanks 谢谢

I believe FaceBook makes its best guess unless you specifically tell it which image to use via a link tag in your page. 我相信FaceBook会做出最好的猜测,除非您通过页面中的链接标签明确告诉它要使用哪个图像。 There's information here: http://wiki.developers.facebook.com/index.php/Facebook_Share/Specifying_Meta_Tags 这里提供信息: http : //wiki.developers.facebook.com/index.php/Facebook_Share/Specifying_Meta_Tags

I imagine Facebook probably looks for images that are from the same domain as the article and then finds the one(s) closest to the text. 我想Facebook可能会查找与文章来自同一域的图像,然后找到最接近文本的图像。 Facebook also allows sites to specify an 'image_src' in their header that it will always use for that page, which makes it much easier for websites to ensure the image they want to be used is used. Facebook还允许网站在其页眉中指定将始终用于该页面的“ image_src”,这使网站更容易确保使用了要使用的图像。

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

See: Documentation on Facebook Sharing 请参阅: Facebook共享文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM