FB OpenGraph og:image,链接一个文件夹?

3

我正在为一个项目添加meta标签,在阅读OpenGraph文档时,每次看到og:image后面总是跟着一个URL。是否可以传递相对路径的文件?

文件结构:

public
   index.html
   images
    staticimage.png

我能直接链接到图片路径吗?

<meta property="og:image" content="./images/staticimage.png" />

到目前为止,似乎它并没有起作用。

1个回答

5
相对 URL 不可用,og:image 属性只能处理完整的 URL。 og:image 属性具有一些可选的结构化属性:
  • og:image:url - 与 og:image 相同。
  • og:image:secure_url - 如果网页需要 HTTPS,则使用的备用 URL。
  • og:image:type - 此图像的 MIME 类型。
  • og:image:width - 宽度(以像素为单位)。
  • og:image:height - 高度(以像素为单位)。
  • og:image:alt - 图像内容的描述(不是标题)。如果页面指定了 og:image,则应该指定 og:image:alt
完整的图像示例:
<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" />

Source: https://ogp.me/#structured


1
啊,好的,我没有看到任何关于相对路径的指示(我需要真正地牢记这个术语),所以想问一下。谢谢! - Mario Carbonell

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接