How does Facebook detect images when adding a link

2019-02-18 18:24发布

问题:

When you add a link to your Facebook page, after some processing, Facebook presents you a next/prev button to choose an image linked to the url your are inserting.

Obviously, Facebook reads the html-page and displays the images found on the url you insert.

Does anyone knows what algorithm Facebook uses to decide what images to show ?

If I insert a link to : http://www.staplijst.be/lachende-wandelaars-aalter-aktivia-003.asp, only 11 images are detected. The one I want, the one at the top right corner, is not included in the list.

If I insert a link to http://www.staplijst.be/stichting-kennedymars-rijsbergen-zundert-nederland-knblo-nl-81996.asp, 19 images are displayed (including the one I want (the one at the right top corner of the text area).

Both pages are build using asp code but are functionally the same.

I thought that it has something to do with the image size, but can't find any deciding factor there.

I will investigate some furhter, because if I know what Facebook is looking for, I can make sure that the correct images are included on the page (since they are dynamic pages build with classic asp).

But if anyone has any idea ? Help would be appreciated.

回答1:

This looks like a duplicate of: Facebook Post Link Image

Use <link rel="image_src" href="abs_url_of_your_image">


回答2:

My guess, is that FB hides repeated images - 'couse a repeated image normally indicates a design-element (not content). When you post a link, only images related to that articles content, are relevant.

So; make sure your image only appears once, and see if it helps!



回答3:

I am not familiar with the way Facebook did it, but I can tell you how I would do it.

  1. Establish web request to desired url
  2. Parse resulted web response with regular expression, that looks for <img src="" />