2015-08-20 29 views
0

如何在我的网站上添加缩略图,以便用户分享到Twitter或Facebook的链接时,它会显示HTML和Javascript中图像的链接? 所以我真正想要的是,当用户在任何社交媒体上共享我的网站的链接时,缩略图图像就会出现在旁边。如何向我的网站添加缩略图,以便在Twitter或Facebook上有人分享链接时显示图像和链接?

我已经把下面我想要的一个链接。

https://twitter.com/Medium/status/634152899132592128

+0

显示你的代码到目前为止你已经尝试过了吗? –

+0

对不起,我不知道从哪里开始。 – Ahan

回答

1

这些被称为微博卡,基本上,你添加<meta>标签到你的网页告诉Twitter什么显示在他们身上。

我认为你正在寻找卡的类型是这个: https://dev.twitter.com/cards/types/summary-large-image

这里是一个例子片段它如何工作(从文档拍摄):

<meta name="twitter:card" content="summary_large_image"> 
<meta name="twitter:site" content="@nytimes"> 
<meta name="twitter:creator" content="@SarahMaslinNir"> 
<meta name="twitter:title" content="Parade of Fans for Houston’s Funeral"> 
<meta name="twitter:description" content="NEWARK - The guest list and parade of limousines with celebrities emerging from them seemed more suited to a red carpet event in Hollywood or New York than than a gritty stretch of Sussex Avenue near the former site of the James M. Baxter Terrace public housing project here."> 
<meta name="twitter:image" content="http://graphics8.nytimes.com/images/2012/02/19/us/19whitney-span/19whitney-span-articleLarge.jpg"> 

他们甚至为您提供的服务来验证和预览卡:
https://cards-dev.twitter.com/validator


对于Facebook而言,<meta>标签是不同的,也很好这里记载: https://developers.facebook.com/docs/sharing/best-practices#tags

由于与Twitter,它们还提供了一个页面,您可以验证并预览: https://developers.facebook.com/tools/debug/

希望帮助!

+0

它说“警告:未列入白名单”。我该如何解决? – Ahan

+0

@ user3675276看起来像视频需要在工作之前加入白名单。这应该有助于您获得批准:https://dev.twitter.com/cards/troubleshooting#approval – vitorbal

0

Facebook将寻找

<meta property="og:image" content="http://weekendtrails.com/screenshot.png" /> 

U可以使用这个元标记为Facebook。我希望它可以与其他网站一起工作

相关问题