Twitter - share button, but with image

后端 未结 4 898
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-13 08:54

I want to use regular share button like on this page https://twitter.com/about/resources/buttons#tweet but to add an embedded image from my site, not just link.

I k

相关标签:
4条回答
  • 2020-12-13 09:04

    Look into twitter cards.

    The trick is not in the button but rather the page you are sharing. Twitter Cards pull the image from the meta tags similar to facebook sharing.

    Example:

    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:site" content="@site_username">
    <meta name="twitter:title" content="Top 10 Things Ever">
    <meta name="twitter:description" content="Up than 200 characters.">
    <meta name="twitter:creator" content="@creator_username">
    <meta name="twitter:image" content="http://placekitten.com/250/250">
    <meta name="twitter:domain" content="YourDomain.com">
    
    0 讨论(0)
  • 2020-12-13 09:08

    I used this code to solve this problem.

    <a href="https://twitter.com/intent/tweet?url=myUrl&text=myTitle" target="_blank"><img src="path_to_my_image"/> </a>
    

    You can check the tweet-button documentation here tweet-button

    0 讨论(0)
  • 2020-12-13 09:13

    You're right in thinking that, in order to share an image in this way without going down the Twitter Cards route, you need to to have tweeted the image already. As you say, it's also important that you grab the image link that's of the form pic.twitter.com/NuDSx1ZKwy

    This step-by-step guide is worth checking out for anyone looking to implement a 'tweet this' link or button: http://onlinejournalismblog.com/2015/02/11/how-to-make-a-tweetable-image-in-your-blog-post/.

    0 讨论(0)
  • 2020-12-13 09:14

    To create a Twitter share link with a photo, you first need to tweet out the photo from your Twitter account. Once you've tweeted it out, you need to grab the pic.twitter.com link and place that inside your twitter share url.

    note: You won't be able to see the pic.twitter.com url so what I do is use a separate account and hit the retweet button. A modal will pop up with the link inside.

    You Twitter share link will look something like this:

    <a href="https://twitter.com/home?status=This%20photo%20is%20awesome!%20Check%20it%20out:%20pic.twitter.com/9Ee63f7aVp">Share on Twitter</a>
    
    0 讨论(0)
提交回复
热议问题