Html 用于社交共享的默认网站图像

Html 用于社交共享的默认网站图像,html,facebook,social-media,Html,Facebook,Social Media,有没有办法设置在Facebook上共享网站时出现的默认图像?我注意到Facebook通常会从站点获取第一张图像作为缩略图使用。您需要设置Facebook图像元标记: <meta property="og:image" content="http://example.com/logo.jpg"> <meta property="og:image:type" content="image/png"> <meta property="og:image:width" con

有没有办法设置在Facebook上共享网站时出现的默认图像?我注意到Facebook通常会从站点获取第一张图像作为缩略图使用。

您需要设置Facebook图像元标记:

<meta property="og:image" content="http://example.com/logo.jpg">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1024">
<meta property="og:image:height" content="1024">

有关更多信息,请查看



图像大小应至少为200px 200px

Facebook的服务器将“刮”您的网站,以便在人们共享图像时使用图像。如果要指定要使用的图像,请将其放入网站的
部分:

Facebook可能缓存了前一张随机图像的副本。要使facebook再次获取,请执行以下操作:

在HTML文档的
中设置如下:

<meta property="og:image" content="http://example.com/ogp.jpg" />

这是开放图协议的一部分,至少受到以下社交媒体网站的尊重:

  • Facebook(见)
  • 推特(见)
  • LinkedIn(见)
  • 谷歌+(见)
  • Pinterest(见)
(……除此之外,可能还有更多。)

除了设置上面的标记外,您还可能需要:

  • 清除社交媒体平台缓存的页面图像版本(例如,使用平台的开发工具),以便立即看到反映的更改。例如,你可以在Facebook上这样做
  • 使用中描述的语法,添加其他“结构化属性”以指定图像的宽度或高度等内容。这被Facebook称为“最佳实践”

    • 这是我的解决方案,它运行良好:

      <head>
          <!--FACEBOOK-->
          <meta property="og:image" content="https://www.website.com/logo.jpg">
          <meta property="og:image:type" content="image/png">
          <meta property="og:image:width" content="1024">
          <meta property="og:image:height" content="1024">
          <meta property="og:type" content="website" />
          <meta property="og:url" content="https://www.website.com/"/>
          <meta property="og:title" content="Website title" />
          <meta property="og:description" content="Website description." />
      <head>
      
      
      

      您可以使用进行测试。

      我使用了这种方法,但它仍然从我的网站上随机选取了一幅图像?我同意-仍在等待答案。只需在我的网站上随机选取一些图像…@MindaugasJačionis根据您需要的只是
      og:image
      标签,可能您当前看到的图像已被缓存,缓存将持续7天。@Rossco您需要删除您网站的所有内容。-1;它不是“facebook图像元标签”,而是一个受支持的协议。这篇文章给我的印象是,这种方法是针对Facebook的,但进一步的研究表明,情况并非如此。共享链接的所有站点的默认设置是什么?这仅仅是Facebook api吗?@JoshYates1980查看更多使用open graph的网站
      <head>
          <!--FACEBOOK-->
          <meta property="og:image" content="https://www.website.com/logo.jpg">
          <meta property="og:image:type" content="image/png">
          <meta property="og:image:width" content="1024">
          <meta property="og:image:height" content="1024">
          <meta property="og:type" content="website" />
          <meta property="og:url" content="https://www.website.com/"/>
          <meta property="og:title" content="Website title" />
          <meta property="og:description" content="Website description." />
      <head>