我在我的一个网站上使用 Open Graph 来丰富从网站分享的帖子。但是 LinkedIn 没有选择 og:image 指定的图片。这个图片被一个简单的 PHP 脚本修改为适合 LinkedIn bot 的 200px X 200px。
我发现一些人遇到了类似的问题 (Linkedin not getting thumbnail image),但这个问题尚未解决。
我在我的一个网站上使用 Open Graph 来丰富从网站分享的帖子。但是 LinkedIn 没有选择 og:image 指定的图片。这个图片被一个简单的 PHP 脚本修改为适合 LinkedIn bot 的 200px X 200px。
我发现一些人遇到了类似的问题 (Linkedin not getting thumbnail image),但这个问题尚未解决。
我知道这个问题有点老,但它仍然有效。
Linkedin会缓存连接预览内容7天。 进行以下操作可以清除Linkedin预览缓存:
步骤 1:访问 https://www.linkedin.com/post-inspector/inspect/
步骤 2:输入您的URL并单击Inspect,您将看到更新后的预览图像。
步骤 3:现在尝试在Linkedin上共享您的URL。
这个问题有点旧,但我也遇到了同样的情况,并找到了解决方案(或者说是我的理解如何解决它),为了帮助其他遇到同样问题的人,我在这里发布我的解决方案。
(感谢@Justin Kominar,在这个问题中的回答帮助了我。)
prefix="og: http://ogp.me/ns#
,当您有iframe时,请确保哪个页面调用了分享功能。<meta>
标签,并将正确的类型给<meta property="og:type>
(请访问ogp.me获取更多信息)。<meta property="og:url>
,特别是当您使用动态网址时。og:url
的页面上(重要的是要理解linkedin会去该页面查找信息而不是您调用分享功能的页面,大多数情况下它们是相同的,但有时并非如此),您需要完成步骤1和2,并设置<meta og:image>
,并确保图像链接有效且图像确实存在。希望这能帮到您。
?linkedin=0
,现在它已经正确地抓取了 OGP 元数据。 - Chunky Chunk<html prefix="og: http://ogp.me/ns#">
<head>
<meta property="og:title" content="My Shared Article Title" />
<meta property="og:description" content="Description of shared article" />
<meta property="og:url" content="http://example.com/my_article.html" />
<meta property="og:image" content="http://example.com/foo.jpg" />
</head>
<body>
…
</body>
</html>
另外,这里还有文档:
https://developer.linkedin.com/docs/share-on-linkedin
同时,使用Facebook Linter检查您的URL(它适用于所有OG标签):
对我来说,问题在于图像大小。一旦我将大小从300像素增加到1200像素
,它就可以工作了。
对于LinkedIn:
- 允许的最大文件大小为5MB。
- 最小图像尺寸应为1200px X 627px。
https://dev.to/samuelorobosa/how-to-handle-linkedin-and-twitter-link-previews-23eg
然而,帖子检查器发现了大小约为750MB的较小图像。因此,真正的值介于300:1200之间。
p.s. gif 在 LinkedIn 上可以使用,但在 Twitter 上只是单个静止帧。
首先,您需要检查您的网站/博客是否已正确放置在HTML文档的标签中的所有元标记。您可以通过将您的网站链接放在https://developers.facebook.com/tools/debug上进行调试来完成此操作。
但是,如果您在Linkedin帖子检查器中无论如何都得到错误的图像,而在Facebook调试器中没有这种情况(两者都使用开放图形标签),则问题出在Linkedin。因此,如果出现这种情况,您可以继续阅读以下内容。
我将我的图像存储在AWS上,因此我使用了2个不同的链接,一个是服务链接,另一个是图像链接。
Linkedin的问题在于它无法读取两个URL。所以您必须正确地进行编码。
我的服务大致如下:
https://d1muf25xaso8hp.cloudfront.net/[IMAGE_URL]?options
示例:
// The service -
https://d1muf25xaso8hp.cloudfront.net/[IMAGE_URL]?options
// Function Input -
https://s3.amazonaws.com/appforest_uf/imageID/200x200.png
// Function Output -
https://d1muf25xaso8hp.cloudfront.net/https%3A%2F%2Fs3.amazonaws.com%2Fappforest_uf%2Ff1643682361025x516549218825449500%2F200x200.png?w=&h=&auto=compress&dpr=1&fit=max
const resizeS3Image = (s3_url) => {
let s3_clean_url = s3_url;
s3_clean_url = s3_clean_url.replace(/\//g, '%2F').replace(/\:/, '%3A');
const cloudFrontCompressedImage = `https://d1muf25xaso8hp.cloudfront.net/${s3_clean_url}?w=&h=&auto=compress&dpr=1&fit=max`;
return cloudFrontCompressedImage;
};
2- 我是如何做到的?使用正则表达式模式和.replace JavaScript本地构造器。
我使用的工具和参考资料
https://www.w3schools.com/tags/ref_urlencode.asp
当您再次在Linkedin Post Inspector上调试您的网站时,请记得在URL后添加“?”后面的内容,例如https://yourwebsite/post/what-is-lorem-impsum?aaaa=912093090 这样,您将更新Linkedin SEO缓存。
<meta>
标签放在<head>
标签内来解决了这个问题。请参考这个答案。 - Ivan Aracki