为什么 WhatsApp link 分享中没有图片?

Why doesn't an image show up in WhatsApp link sharing?

我正在尝试使用 Open Graph 数据丰富网站,让页面作者决定在社交媒体预览中显示哪些图像和文本。但是,我无法让 WhatsApp 在分享卡中显示小图片。

我当前的标记如下所示:

<meta property="og:url" content="https://dev.firapeel.nl/activiteiten/%CE%A3%CF%89%CE%BA%CF%81%CE%AC%CF%84%CE%B7%CF%82">
<meta property="og:title" content="Σωκράτης">
<meta name="description" content="Excerpt of Greek text, something by Plato">
<meta property="og:description" content="Excerpt of Greek text, something by Plato">
<meta property="og:image" content="https://dev.firapeel.nl/img/opengraphtest/the-alps-4440879_1920.jpg?type=open_graph">
<meta property="og:image:width" content="600">
<meta property="og:image:height" content="315">

当我阅读 this answer closely, I think I comply with all mentioned requirements, and the image is less than 300KB and larger than 300x200. For testing purposes, here 是包含此数据的页面(页面不会永远在线,但至少只要没有被接受的答案)。

令我震惊的是 this page 确实在 WhatsApp 上生成了预览图像,所以我查看了它的标记:

<meta property="og:type" content="website" />
<meta property="og:site_name" content="The Criterion Collection" />
<meta property="og:title" content="Jack Reynor’s Top 10" />
<meta property="og:url" content="https://www.criterion.com/current/top-10-lists/365-jack-reynor-s-top-10" />
<meta property="og:description" content="A voracious cinephile with wide-ranging taste, the star of Midsommar shares a list of favorite films that shows his particular affinity for the provocative and the macabre." />
<meta property="og:image" content="https://s3.amazonaws.com/criterion-production/explore_images/1163-be829752be16371f35aad962dd0ee8dd/EqV7Y9BOuhZMNvHkcEmghaSAykI5cd_original.jpg" />
<meta content="https://s3.amazonaws.com/criterion-production/explore_images/1163-be829752be16371f35aad962dd0ee8dd/EqV7Y9BOuhZMNvHkcEmghaSAykI5cd_original.jpg" property="thumbnail" />

郑重声明,链接图片的尺寸为 1600x1600。

所以我尝试摆脱图像大小属性,使用更大的图像(尺寸为 1920x1079,并且没有查询参数),使用 300x300 的正方形图像,使用 thumbnail meta 属性,使用不需要 URL 编码实体的页面进行测试,但无论我尝试哪种组合,都没有任何效果。

更新:

根据 Cosmin Staicu 的回答,URL 中的希腊字符似乎是问题所在,所以我选择了仅包含 latin1 字符的 another page,但这对我来说没有任何改变:

您的 og 实现仅适用于某些版本的 whats app。那是因为 url(整个页面的,而不仅仅是图像)包含非 ascii 字符。

我的一个网站上有 copy/paste 您的 html 代码,只要文件名为 index.html 或 ogtest.html,它就可以正常工作。

在我用希腊字符重命名文件后,og-protocol 停止工作了。

与此同时,我更改了服务器应用程序的结构:最初,我使用 PHP 脚本提供图像,该脚本将 URI 请求转换为内部文件名。由于服务器过载,这会在一次请求许多图像时导致 503 "Service Unavailable" 错误。

所以我决定将所有图片放在一个可公开访问的目录中,让 Apache 直接处理图片请求。这不仅大大加快了速度,而且作为副作用,这个问题也得到了解决。

在我的例子中,whatsup 上的共享 post 确实显示了缩略图,所以我通过将 img 格式更改为 .jpg 并将其大小更改为 <300 kb 来修复。

先决条件是我使用的是 Yoast SEO 和 Anyshare 插件。