views:

130

answers:

2

Hi,

I'm wondering how facebook extracts the right picture of the article from a link? 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?

Thanks

A: 

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 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.

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

See: Documentation on Facebook Sharing

animuson
Unfortunately this stopped working a few weeks ago. So far I did not find a reason and how to get it working again. Really annoying that things just stop working on facebook.
Alex
It worked for me just a couple days ago.
animuson
+2  A: 

I believe FaceBook makes its best guess unless you specifically tell it which image to use via a link tag in your page. There's information here: http://wiki.developers.facebook.com/index.php/Facebook_Share/Specifying_Meta_Tags

Greg Charles