我刚刚注意到 facebook 上的一个共享链接,其预览中的图像未包含在页面本身中(至少不可见)。所以我想知道——当使用 HTML 代码共享链接时,是否有任何方法可以指定缩略图/预览中可以显示哪些图像?
我能想到的唯一方法是在页面上有一个可用于预览的 0px 图像。这是通常的做法吗?
最佳答案
这可以使用 facebook open graph meta 标签来实现: http://swarminglabs.com/facebook-open-graph-meta-tags/
<meta property="og:title" content="Awesome, Inc. – We're even more awesome.">
<meta property="og:description" content="Awesome's mission is to take cool to a whole new level.">
<meta property="og:image" content="http://YOURWEBSITE.com/YOURIMAGE.png">
<meta property="og:image:secure_url" content="https://YOURWEBSITE.com/YOURIMAGE.png">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1500">
<meta property="og:image:height" content="1500">
使用 og:image
元标记将图像更改为您想要的。
关于facebook - Facebook 如何获取 URL 元数据以在共享链接中显示为预览?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19566982/