Facebook Share Story Image Does Not Appear For First time

☆樱花仙子☆ 提交于 2019-11-27 16:23:36

https://developers.facebook.com/docs/sharing/best-practices#precaching lists ways to avoid this problem, by either

  • scraping new articles upfront via API, or

  • specifying the image dimensions via OG meta tags as well.

UPDATE

This solution with iframe is not working anymore! Worked since yesterday 06 February 2017. Facebook just set X-Frame-Options as DENY so you cannot load the sharer url in an iFrame. I'm figuring out another workaround.


I struggled to find a solution for this facebook bug (adding og:image:width and og:image:height was not enough).

Finally I came up with a workaround that worked: I added an hidden iFrame with the sharer link in the page footer; in this way the facebook crawler check the page once is loaded and, when you click facebbok share button in the first time you can see the shared image!

Example:

<iframe style="width: 0px; height: 0px; margin: 0px; padding: 0px;" src="https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.example.com"></iframe>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!