Open Graph Protocol. How to determine if Facebook is

On LinkedIn, here "the image must be at least 80 x 150 pixels." On Facebook , the image here "cannot exceed 130x110 pixels." I want to use the php function to resize thumbnails for Facebook or LinkedIn.

How can I determine if there is Facebook or LinkedIn when I share the link?

EDIT (details):

When I embed a link to share it on Facebook or LinkedIn, they get the information that is in these tags inside the header of the html document:

<meta property="og:url" content="..." /> <meta property="og:description" content="..." /> <meta property="og:image" content="image.jpg" /> <meta property="og:title" content="title" /> <meta property="og:type" content="website" /> <meta property="fb:app_id" content="id..." /> <meta property="og:locale" content="en_US" /> 

For the og: image part for LinkedIn, if it is smaller than the size, it ignores it, while for Facebook the maximum required is less than what LinkedIn requires, and on Facebook for the wrong picture, this is the default image. So I'm trying to determine if I can share the link on Facebook or LinkedIn to resize

0
source share
1 answer

Look at the user agent of the request if it then Facebook will use the optimized image on Facebook, otherwise - by default (with reference to the size).

 facebookexternalhit/1.1 (+https://www.facebook.com/externalhit_uatext.php) 

Source: Open Graph protocol, Best Practices section .

NOTE. Although this is not the purpose of this user agent (it is not clear what is allowed and not allowed). But I think your goal will not violate any platform policies.

+3
source

Source: https://habr.com/ru/post/955201/


All Articles