Facebook 表示开放图形图像的内容类型无效并忽略它

问题描述 投票:0回答:2

我试图找出 Facebook 忽略 OpenGraph 图像的原因。 他们的共享调试器说它会忽略图像,因为它的内容类型无效。

为博客提供的所有图像(上传的图像)都会发生这种情况,但静态图像不会发生这种情况,以下是每种图像的一个示例:

最初图像是 png 图像,我尝试将其编码为 jpeg 但它没有改变任何东西

我还在不同的开放图工具上尝试了相同的链接,其中大多数都按我希望的方式工作:

只有 LinkedIn 给了我同样的结果:

https://www.linkedin.com/post-inspector/inspect/https:%2F%2Fwww.coworkees.com%2Fblog%2F14867

它说它考虑了其他值,但没有解释为什么它忽略了 og:image one

知道什么可能会导致这个问题或者我该如何调试它?

image http-headers facebook-opengraph mime-types
2个回答
1
投票

添加 og:image:type 元标记。

<meta data-n-head="ssr" data-hid="og:image:type" property="og:image:type" content="image/png">

我的图像返回了正确的图像类型标头,但 Facebook 仅在添加此元标记后才接受图像。我在 Facebook(或其他任何地方)中没有发现任何参考资料表明这就是所需要的。


0
投票

为图像添加缺少的元,如下所示:

<meta property="og:image" content="https://example.com/ogp.jpg" />
<meta property="og:image:secure_url" content="https://secure.example.com/ogp.jpg" />
<meta property="og:image:type" content="image/jpeg" />
<meta property="og:image:width" content="400" />
<meta property="og:image:height" content="300" />
<meta property="og:image:alt" content="A shiny red apple with a bite taken out" />

从官方文档了解更多信息:https://ogp.me/#structed

© www.soinside.com 2019 - 2024. All rights reserved.