Facebook 链接缩略图
当在 Facebook 上发布某个网站的链接(Google+ 和其他网站也算在内)时,您会收到一个缩略图或可供选择的缩略图。这些是 HTML 中的标签。
我一直认为使用 CSS 将我的徽标作为 h1 标签内的背景图像是一种很好的做法。我将 h1 标记设为返回主页的链接,并使用 {text-indent: -9999px} 之类的内容隐藏标题文本,留下一个可爱的语义 HTML 标题。如果您想查看,这里有一个指向我网站的链接: http://tempertemper.net
问题在于,因为它是被忽略的背景图像。
仅出于此目的在 HTML 顶部发布自定义并将其隐藏在页面一侧是个好主意吗?不知道,好像有点乱。我可以将标签放在 h1 内,但徽标的形状不正确,因为它是为特定目的而设计的。
也许有一个用于此目的的元标记,或者可能有一种技术可以强制 FB 提取未正常加载的特定图像?有人对此有什么想法或重要提示吗?
When posting a link to a website in Facebook (Google+ and the rest count too) you're given a thumbnail, or selection of thumbnails to choose from. These are tags from the HTML.
I've always been of the opinion that it was good practice to make my logo a background image inside a h1 tag using CSS. I make the h1 tag a link back to the home page and hide the header text with something like {text-indent: -9999px}, leaving a lovely semantic HTML header. Here's a link to my site if you want a look: http://tempertemper.net
The problem with this is that as it's a background image it's overlooked.
Would it be a good idea to post a custom at the top of the HTML for this purpose only, and hide it off the side of the page? I don't know, seems a bit messy. I could just put the tag inside the h1, but the logo wouldn't be the right shape as it's designed for a specific purpose.
Maybe there's a meta tag for this purpose or maybe there's a technique to force FB to pull a specific image that isn't loaded normally? Does anyone have any ideas or top tips for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
是的,您可以设置元标记,以便 Facebook 知道要选择哪个图像。
请参阅: https://developers.facebook.com/docs/opengraph/
具体来说,它是
og:image
属性,它会告诉 Facebook 的链接共享脚本选择该图像作为其缩略图。请记住,尽管 Facebook 会进行一些缓存,所以如果您已经共享过链接一次,它可能仍然“卡在”使用旧图像上。
您可以使用 Facebook URL Linter 查看 Facebook 从您的网站获取的内容。请参阅:http://developers.facebook.com/tools/lint/(使用URL Linter 还将重建 Facebook 的缓存)
Yes, you can set a meta tag so that Facebook knows which image to pick.
See: https://developers.facebook.com/docs/opengraph/
Specifically, it is the
og:image
property, and it will tell Facebook's link share script to choose that image as its thumbnail.Keep in mind though that Facebook does some caching, so if you've already shared the link once it may still be "stuck" on using the older image.
You can see whats Facebook getting out of your website by using the Facebook URL Linter. See: http://developers.facebook.com/tools/lint/ (The use of the URL Linter will also rebuild Facebook's cache)
有一个元标签可以让应用程序(例如 FB)知道您想要拍摄特定的图像,而不是让用户选择一张。
对于 Facebook,还有另一种方法可以通过使用开放图谱协议来实现这一目标。
您需要准备您的网站以使用 og: 标签,方法是在 html 标签中添加 og 命名空间:
然后您就可以使用 og: 元标签,如下所示:
对于 Facebook,需要这六个 og 元标签:
您可以在以下位置找到更多 og: 类型的附加信息:https://developers.facebook.com/docs/opengraph/
There is a Meta-Tag to let the Application (like FB) know that you want a specific image taken rather than let the user choose one.
For Facebook there is also an other Way to achieve this by using Open Graph protocol.
You need to prepare your Website for using og: Tags by adding the og-Namespace in your html-Tag:
Then you are able to use the og: Meta-Tags like this:
For Facebook this six og Meta-Tags are required:
You can find additional information an more og: types at: https://developers.facebook.com/docs/opengraph/
就像其他人回答的那样,但它只适用于我使用 (https)
而不是
Like others have answered but it only works for me when i use (https)
Instead of
如果您确实喜欢 img 但在 css 中放置
图像不会显示在页面上但我不知道 facebook 是否会看到该图像怎么办
what if you did like a img but in css put
the image would not show up on the page but i don't know if facebook would see the image
正如已经说过的:最好是将元标记与
og:image
opengraph 属性一起使用。除此之外:Facebook 并不是唯一使用 opengraph 元标签的平台。 Google+ 或 Xing 也更喜欢它。不太清楚其他人的情况...
As already said: Best would be to use the metatag with the
og:image
opengraph property.In addition to that: Facebook is not the only platform using the opengraph metatags. Also Google+, or Xing are preferring it. Not sure about others...