javascript - How do I add a thumbnail to my website so that when someone shares a link on Twitter or Facebook it shows the image

How do I add a thumbnail to my website so when a user shares the link to Twitter or Facebook it shows t

How do I add a thumbnail to my website so when a user shares the link to Twitter or Facebook it shows the link with the image in HTML and Javascript? So what I exactly want is that when the user shares the link of my website on any social media a thumbnail image es beside it.

I've put a link of what I want below.

How do I add a thumbnail to my website so when a user shares the link to Twitter or Facebook it shows the link with the image in HTML and Javascript? So what I exactly want is that when the user shares the link of my website on any social media a thumbnail image es beside it.

I've put a link of what I want below.

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

Share Improve this question edited Aug 20, 2015 at 9:55 KidCoder asked Aug 20, 2015 at 5:50 KidCoderKidCoder 3636 silver badges18 bronze badges 2
  • show your code what you have tried so far ? – Amit singh Commented Aug 20, 2015 at 5:51
  • Sorry, I don't know where to begin. – KidCoder Commented Aug 20, 2015 at 5:52
Add a ment  | 

2 Answers 2

Reset to default 2

Those are called twitter cards and basically, you add <meta> tags to your page to tell Twitter what to show on them.

I think the type of card you are looking for is this one: https://dev.twitter./cards/types/summary-large-image

Here is a snippet with examples how it would work (taken from the docs):

<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./images/2012/02/19/us/19whitney-span/19whitney-span-articleLarge.jpg">

They even provide you with a service to validate and preview the cards:
https://cards-dev.twitter./validator


For Facebook, the <meta> tags are different and are also well documented here: https://developers.facebook./docs/sharing/best-practices#tags

As with Twitter, they also provide a page where you can validate and preview: https://developers.facebook./tools/debug/

Hope that helps!

Facebook will look for

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

U can use this meta tag for facebook. I hope it will work with other sites also

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745441164a4627838.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信