Facebook share not showing image from open graph metatags

前端 未结 3 2269
北荒
北荒 2021-02-19 11:21

I\'m trying to integrate the Facebook share button to my employer\'s site, the title, url, description/intro are all displaying correctly, however no image is being attached. Wh

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-19 11:56

    In my experience :

    • All the URLs should be absolute (even the og:image value)
    • If your image is served equally over https you should add a og:image:secure_url meta property with absolute url as well (if you serve everything only over https you can skip this)
    • Add as well a og:image:width and og:image:height meta properties

    Main url redirection is very tricky, you should make absolutely sure your content is correctly (and fully) fetched, for complex dynamic content I often end up doing a detection in the .htaccess to serve FB’s crawler appropriate content as follow :

    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} facebookexternalhit/[0-9]
    RewriteRule ^(.*)$ OG_GENERATOR_SCRIPT_HERE.php [L,QSA]
    

提交回复
热议问题