如何在 Facebook 上实现分享时将特定图像显示为缩略图?

发布于 2024-07-15 13:34:49 字数 325 浏览 8 评论 0原文

我正在尝试实现分享这个方法。 我使用的代码如下,

http://www.facebook.com/share.php?u=my_website_url

现在当 Facebook 显示它时,它在左侧显示一些缩略图。 这些图片是从我的网站上挑选的。 如何选择特定图像作为缩略图或至少停止显示缩略图?

您可以通过我的博客地址查看。

I am trying to implement share this method. I am using the code as follows

http://www.facebook.com/share.php?u=my_website_url

Now when Facebook is showing it showing some thumbnails at left side. These images are picked from my website. How can I pick a particular image as thumbnail or at least stop it showing thumbnail?

You can check it with my blog address.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

深海少女心 2024-07-22 13:34:49

根据 Facebook 的规范,使用如下代码:

<meta property="og:image" content="http://siim.lepisk.com/wp-content/uploads/2011/01/siim-blog-fb.png" />

来源:Facebook Share

From Facebook's spec, use a code like this:

<meta property="og:image" content="http://siim.lepisk.com/wp-content/uploads/2011/01/siim-blog-fb.png" />

Source: Facebook Share

场罚期间 2024-07-22 13:34:49

这篇博文似乎有你的答案:
http://blog.capstrat.com/articles/facebook-share -thumbnail-image/

具体来说,使用如下标记:

<link rel="image_src" 
      type="image/jpeg" 
      href="http://www.domain.com/path/icon-facebook.gif" />

图像的名称必须与示例中的名称相同。

单击“确保预览有效”

注意:根据 Facebook 的文档,标签可能是正确的,但 Facebook 仅每 24 小时抓取一次。 使用 Facebook Lint 页面将图像导入 Facebook。

http://developers.facebook.com/tools/lint/

This blog post seems to have your answer:
http://blog.capstrat.com/articles/facebook-share-thumbnail-image/

Specifically, use a tag like the following:

<link rel="image_src" 
      type="image/jpeg" 
      href="http://www.domain.com/path/icon-facebook.gif" />

The name of the image must be the same as in the example.

Click "Making Sure the Preview Works"

Note: Tags can be correct but Facebook only scrapes every 24 hours, according to their documentation. Use the Facebook Lint page to get the image into Facebook.

http://developers.facebook.com/tools/lint/

烟雨扶苏 2024-07-22 13:34:49

根据 Facebook 的文档,我的标签是正确的,但他们每 24 小时才会抓取一次。 使用 Facebook Lint 页面将图像导入 Facebook。

在此处输入您的 URL,FB 将更新您页面中的元数据:

https://developers.facebook.com/tools /debug(更新的链接)

My tags were correct but Facebook only scrapes every 24 hours, according to their documentation. Using the Facebook Lint page got the image into Facebook.

Enter your URL here and FB will update the metadata from your page:

https://developers.facebook.com/tools/debug (updated link)

短叹 2024-07-22 13:34:49

Facebook 使用 og:tags开放图谱协议 来解读预览时要显示的信息分享对话框中的网址
或者在 Facebook 的新闻提要中。

og:tags 包含以下信息:

  • 页面标题
  • 页面类型
  • URL
  • 网站名称
  • 页面描述
  • 页面管理员的 Facebook user_id(位于facebook )

以下是一些 og:tags 的示例(取自 facebook 文档




一旦您实现了正确的标记og:tags 并设置它们的值,您可以使用 Facebook 调试器测试 facebook 如何查看您的 URL 。 调试器工具还将突出显示它在页面上发现的 og:tags 或缺少的任何问题。

需要记住的一件事是,Facebook 确实对此信息进行一些缓存,因此为了使更改生效,您的页面将不会被抓取,如所述在文档中:

编辑元标签

您可以通过更新页面的属性来更新页面的属性
标签。 请注意,og:title 和 og:type 只能编辑
最初 - 当您的页面收到 50 个赞后,标题就会固定,
当你的页面收到 10,000 个赞后,类型就固定了。
这些属性是固定的,以避免让喜欢的用户感到惊讶
页面已经。 在这些限制之后更改标题或类型标签
已到达 不执行任何操作,您的页面保留原始标题并且
类型。

为了使更改反映在 Facebook 上,您必须强制您的页面
被刮掉。 当页面管理员点击时,页面会被抓取
点赞按钮或将 URL 输入到 Facebook URL 中时
Linter
Facebook 调试器...

Facebook uses og:tags and the Open Graph Protocol to decipher what information to display when previewing your URL in a share dialog
or in a news feed on facebook.

The og:tags contain information such as :

  • The title of the page
  • The type of page
  • The URL
  • The websites name
  • A description of the page
  • Facebook user_id's of administrators of the page ( on facebook )

Here is an example ( taken from the facebook documentation ) of some og:tags

<meta property="og:title" content="The Rock"/>
<meta property="og:type" content="movie"/>
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/"/>
<meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>

Once you have implemented the correct markup of the og:tags and set their values, you can test how facebook will view your URL by using the Facebook Debugger. The debugger tool will also highlight any problems it finds with the og:tags on the page or lack there-of.

One thing to keep in mind is that facebook does do some caching with regard to this information, so in order for changes to take effect your page will have t be scraped as stated in the documentation :

Editing Meta Tags

You can update the attributes of your page by updating your page's
tags. Note that og:title and og:type are only editable
initially - after your page receives 50 likes the title becomes fixed,
and after your page receives 10,000 likes the type becomes fixed.
These properties are fixed to avoid surprising users who have liked
the page already. Changing the title or type tags after these limits
are reached does nothing, your page retains the original title and
type.

For the changes to be reflected on Facebook, you must force your page
to be scraped. The page is scraped when an admin for the page clicks
the Like button or when the URL is entered into the Facebook URL
Linter
Facebook Debugger...

甜柠檬 2024-07-22 13:34:49

我看到提供的所有答案都是正确的。 然而,一个重要的细节被忽视了:图像的大小必须至少为 200 X 200 像素,否则 Facebook 将用符合页面上标准的第一个可用图像替换缩略图。 另一个事实是,最少需要包含 Facebook 为 og:image 生效所需的 3 个元数据:

<meta property="og:title" content="Title of the page" />
<!-- NEXT LINE Even if page is dynamically generated and URL contains query parameters -->
<meta property="og:url" content="http://yoursite.com" />
<meta property="og:image" content="http://convertaholics.com/convertaholics-og.png" />

使用 Facebook 调试器调试您的页面并修复所有警告,它应该会像魅力一样工作!
https://developers.facebook.com/tools/debug

I see that all the answers provided are correct. However, one important detail was overlooked: The size of the image MUST be at least 200 X 200 px, otherwise Facebook will substitute the thumbnail with the first available image that meets the criteria on the page. Another fact is that the minimum required is to include the 3 metas that Facebook requires for the og:image to take effect:

<meta property="og:title" content="Title of the page" />
<!-- NEXT LINE Even if page is dynamically generated and URL contains query parameters -->
<meta property="og:url" content="http://yoursite.com" />
<meta property="og:image" content="http://convertaholics.com/convertaholics-og.png" />

Debug your page with Facebook debugger and fix all the warnings and it should work like a charm!
https://developers.facebook.com/tools/debug

莫相离 2024-07-22 13:34:49

我也遇到了同样的问题,并且相信我已经解决了。 我使用此处提到的链接元标记来指向我想要的图像,但关键是,如果您这样做,FB 将不会拉取任何其他图像作为选择。 另外,如果您的图像太大,您将根本没有任何选择。

以下是我修复网站的方法 http://gnorml.com/blog/facebook-link-thumbnails /

I was having the same problems and believe I have solved it. I used the link meta tag as mentioned here to point to the image I wanted, but the key is that if you do that FB won't pull any other images as choices. Also if your image is too big, you won't have any choices at all.

Here's how I fixed my site http://gnorml.com/blog/facebook-link-thumbnails/

独行侠 2024-07-22 13:34:49

其工作原理如下:

  1. 您需要能够访问您正在共享的特定网页上的 HTML。 如果您使用通用头文件,它也可能在整个站点范围内工作。 我没有尝试过这个,但它应该有效。 如果您这样做,您只会在所有页面上获得相同的图像。

  2. 您需要将这些 HTML 元标记添加到 . 如果你把它放在 . 确保根据您的 a) 图像、b) 描述、c) URL 和 d) 标题进行自定义。

一个真实的例子。

<meta property="og:image" content="http://www.coachesneedsocial.com/wp-content/uploads/2014/12/BannerWCircleImages-1.jpg" />

<meta property="og:description" content="Coaches share their secrets to success so you can rock 2015." />

<meta property="og:url"content="http://www.coachesneedsocial.com/coacheswisdomtelesummit/" />

<meta property="og:title" content="Coaches Wisdom Telesummit" />
  1. 保存
  2. 打开新的 Facebook 帖子,然后重试您要共享的页面。
  3. 如果您遇到问题...您可以使用此 Facebook 工具进行调试。 它看起来比实际更极客。 当您在 URL 中发布内容进行共享时,它会告诉您 Facebook 看到了什么。

https://developers.facebook.com/tools/debug/og/object/< /a>

大提示.. 确保 HTML 中的“引号”相同(它们应该看起来像 2 个直线标记,没有曲线……有时程序会将它们更改为不同的字体,从而使代码变得混乱。

Here’s how this works all:

  1. You need the ability to access the HTML on the particular webpage you are sharing. It'll probably work site wide too if you use a common header file. I have not tried this, but it should work. You'll just get the same image for all pages if you do this though.

  2. You need to add these HTML meta tags into page in the . It will not work if you put it in the . Make sure to customize per your a) image, b) description, c) URL, and d) title.

A Real Example.

<meta property="og:image" content="http://www.coachesneedsocial.com/wp-content/uploads/2014/12/BannerWCircleImages-1.jpg" />

<meta property="og:description" content="Coaches share their secrets to success so you can rock 2015." />

<meta property="og:url"content="http://www.coachesneedsocial.com/coacheswisdomtelesummit/" />

<meta property="og:title" content="Coaches Wisdom Telesummit" />
  1. Save
  2. Open a fresh Facebook post, and retry the page you wanted to share.
  3. If you are having trouble… you can debug it with this Facebook tool. It looks more geeky than it is. It tells you what Facebook is seeing when you post in the URL to share.

https://developers.facebook.com/tools/debug/og/object/

Big Tip.. make sure the “quote marks” are the same in your HTML (they should look like 2 straight marks and no curves… sometimes programs change these to different fonts and it goofs up the code.

何时共饮酒 2024-07-22 13:34:49

在 Facebook 上分享:如何通过自定义图像、标题和文本来改善结果

来自上面的链接。 为了获得最佳的共享效果,您需要在 HTML 中建议 3 条数据:

  • 标题
  • 简短描述
  • 图片

这可以通过以下内容完成,放置在 HTML 的“head”标签内:

  • 标题:< ;title>插入帖子标题
  • 图片:
  • 说明:

如果您的网站是静态 HTML,则必须使用 HTML 编辑器对每个页面执行此操作。

如果您使用 Drupal 之类的 CMS,您可以将很多工作自动化(参见上面的链接)。 如果您使用 WordPress,您可能可以使用 Drupal 示例作为指导来实现类似的东西。 我希望您发现这些有用。

最后,您始终可以手动编辑您的分享帖子。 请参阅此示例带插图

Sharing on Facebook: How to Improve Your Results by Customizing the Image, Title, and Text

From the link above. For the best possible share, you'll want to suggest 3 pieces of data in your HTML:

  • Title
  • Short description
  • Image

This accomplished by the following, placed inside the 'head' tag of your HTML:

  • Title: <title>INSERT POST TITLE</title>
  • Image: <meta property=og:image content="http://site.com/YOUR_IMAGE.jpg"/>
  • Description: <meta name=description content="INSERT YOUR SUMMARY TEXT"/>

If you website is static HTML, you'll have to do this for every page using your HTML editor.

If you're using a CMS like Drupal, you can automate a lot of it (see above link). If you use wordpress, you can probably implement something similar using the Drupal example as a guideline. I hope you found these useful.

Finally, you can always manually edit your share posts. See this example with illustrations.

梦情居士 2024-07-22 13:34:49

我上周工作的网站也遇到了问题。 我实现了一个like box并测试了like box。 然后我继续将图像添加到我的标题中(ob:image 元)。 正确的图像仍然没有出现在我的 Facebook 通知上。

我尝试了所有方法,并得出结论:“点赞”按钮的每个实现都会被缓存。 假设您点击了 url A 上的 Like 按钮,然后在标题中指定了一个图像,并通过再次单击 url A 上的 Luke 按钮来测试它。您将看不到该图像,因为页面已被缓存。 当您单击页面 B 上的 Like 按钮时,该图像将显示。

要重置缓存,您必须使用上面提到的 lint 调试器工具,并验证缓存的所有 URL...这是唯一的事情这对我有用。

I also had an issue on a site I was working on last week. I implemented a like box and tested the like box. Then I went ahead to add an image to my header (the ob:image meta). Still the correct image did not show up on my facebook notification.

I tried everything, and came to the conclusion that every single implementation of a like button is cached. So let's say you clock the Like button on url A, then you specify an image in the header and you test it by clicking the Luke button again on url A. You won't see the image as the page is cached. The image will show up when you click on the Like button on page B.

To reset the cache, you have to use the lint debugger tool that's mentioned above, and validate all the Urls for those that are cached... That's the only thing that worked for me.

Hello爱情风 2024-07-22 13:34:49

我发现为每篇 Joomla 文章设置 Facebook Open Graph 的最简单方法是放置在 com_content/article/default.php 覆盖中,下一个代码:

$app    = JFactory::getApplication();
$path   = JURI::root();

$document = JFactory::getDocument();
$document->addCustomTag('<meta property="og:title" content="YOUR SITE TITLE" />');
$document->addCustomTag('<meta property="og:name" content="YOUR SITE NAME" />');
$document->addCustomTag('<meta property="og:description" content="YOUR SITE DESCRIPTION" />');
$document->addCustomTag('<meta property="og:site_name" content="YOUR SITE NAME" />');
if (isset($images->image_fulltext) and !empty($images->image_fulltext)) : 
    $document->addCustomTag('<meta property="og:image" content="'.$path.'<?php echo htmlspecialchars($images->image_fulltext); ?>" />');
else :
    $document->addCustomTag('<meta property="og:image" content="'.$path.'images/logo.png" />');
 endif;

这将在头部放置元标签,其中包含当前文章的详细信息。

The easiest way I found to set Facebook Open Graph to every Joomla article, was to place in com_content/article/default.php override, next code:

$app    = JFactory::getApplication();
$path   = JURI::root();

$document = JFactory::getDocument();
$document->addCustomTag('<meta property="og:title" content="YOUR SITE TITLE" />');
$document->addCustomTag('<meta property="og:name" content="YOUR SITE NAME" />');
$document->addCustomTag('<meta property="og:description" content="YOUR SITE DESCRIPTION" />');
$document->addCustomTag('<meta property="og:site_name" content="YOUR SITE NAME" />');
if (isset($images->image_fulltext) and !empty($images->image_fulltext)) : 
    $document->addCustomTag('<meta property="og:image" content="'.$path.'<?php echo htmlspecialchars($images->image_fulltext); ?>" />');
else :
    $document->addCustomTag('<meta property="og:image" content="'.$path.'images/logo.png" />');
 endif;

This will place meta og tags in the head with details from current article.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文