OG 图像高度和宽度不会应用于图像,即使它们出现在 html 中

OG image height and width are not applied to image, even though they appear in html

提问人:Rebecca 提问时间:11/8/2023 更新时间:11/8/2023 访问量:21

问:

我已经为我的 Rails 7 网站定义了 OG 元数据,包括图像。我正在使用元标签 gem 来设置元数据。

当我使用 Facebook 调试器工具 (https://developers.facebook.com/tools/debug/) 时,我看到图像没有呈现为正方形 (400 x 400),当我在 WhatsApp 中测试时,图像根本没有呈现(可能是因为它太大了)。

即使 html 呈现高度和宽度,似乎也没有应用这些尺寸。

def set_social_meta_tags
    set_meta_tags title: t("layouts.header.parks"),
                  description: t("layouts.footer.tag_line"),
                  og: {
                    title: :title,
                    description: :description,
                    type: "website",
                    url: "https://example.com" + request.path,
                    image: { _: "https://example.jpeg", width: 400, height: 400}
                  },
                  twitter: {
                    card: "summary",
                    description: :description,
                    title: :title,
                    image: { _: "https://example.jpeg", width: 400, height: 400}
                  }
  end

html 呈现如下:

<meta property="og:image" content="https://myasset.jpeg">
<meta property="og:image:width" content="400">
<meta property="og:image:height" content="400">
HTML CSS Ruby-on-Rails 元数据 元标记

评论


答: 暂无答案