【问题标题】:Trying to set the image in sharing at google+, facebook, twitter via HTML尝试通过 HTML 将图像设置为在 google+、facebook、twitter 上共享
【发布时间】:2015-07-24 02:07:40
【问题描述】:

我正在尝试让 google+、facebook 和 twitter 显示我在分享时选择的图像。我写了一个应该是的html代码,但由于某种原因它不起作用。那是在身体里:

<a href="https://www.facebook.com/sharer/sharer.php?u=incodedURL" target="_blank">
    <img src="other/facelog.png" alt="Facebook Logo" id="facelog"></a>

<a href="https://plus.google.com/share?url=incodedURL" target="_blank">
    <img src="other/googlog.png" alt="Google Plus Logo" id="googlog"></a>

<a href="https://twitter.com/intent/tweet?url=incodedURL" target="_blank">
    <img src="other/twitlog.png" alt="Twitter Logo" id="twitlog"></a>

在头脑中,我尝试了来自 1234 的 Open Graphs、元标记和项目道具。

还有很多其他的,但它们都不起作用。我的图片、标题和说明未显示。我正在使用 450x450 像素的 .jpg 图像。 HTML。

【问题讨论】:

  • 顺便说一句 - 网站不在本地主机上,并尝试从网络和文件夹中添加图像。

标签: html facebook twitter share


【解决方案1】:

您需要为此使用元标记。
以下是所有 3 个社交网络的元标记列表:

<!-- Schema.org markup for Google+ -->
<meta itemprop="name" content="The Name or Title Here">
<meta itemprop="description" content="This is the page description">
<meta itemprop="image" content="http://www.example.com/image.jpg">

<!-- Twitter Card data -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@publisher_handle">
<meta name="twitter:title" content="Page Title">
<meta name="twitter:description" content="Page description less than 200 characters">
<meta name="twitter:creator" content="@author_handle">
<!-- Twitter summary card with large image must be at least 280x150px -->
<meta name="twitter:image:src" content="http://www.example.com/image.jpg">

<!-- Facebook - Open Graph data -->
<meta property="og:title" content="Title Here" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://www.example.com/" />
<meta property="og:image" content="http://example.com/image.jpg" />
<meta property="og:description" content="Description Here" />
<meta property="og:site_name" content="Site Name, i.e. Moz" />
<meta property="fb:admins" content="Facebook numberic ID" />

在 Facebook 案例中,您可以使用Debugger tool 来检查这些元标记是否被正确实施。

【讨论】:

  • 我告诉过你,这些都行不通。这是我试图找到解决方案的问题。我刚刚复制了所有代码并更改了一些值(图片和 URL),但它仍然不起作用。我在问题中写道,我已经尝试了这一切。我只是不明白,可能是什么问题......
  • 您有想要分享的页面的链接吗?
  • 嗯...你能分享一下吗,这样我们就可以看到发生了什么并使用 Facebook 调试器删除 URL?如果您已删除它们,请再次添加我的答案中的元标记
  • 我没有删除任何元标记。我不会分享网址。这是一个普通的带有css和js的html页面。
  • Facebook 调试器工具和页面报废至少可以说令人沮丧。我发现添加一个版本查询参数,如http://example.com?v=1,然后单击调试会欺骗它查看一个新的 url,它将要求获取详细信息。每次您想尝试新的 scape 时,请更改版本查询参数值的值。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-01-28
  • 2017-09-08
  • 1970-01-01
  • 2014-01-14
  • 2014-11-26
  • 1970-01-01
  • 2014-12-25
相关资源
最近更新 更多