Reputation: 91213
Is it possible to attach an image to a tweet via Twitter's Web Intents? Right now, if you put an image in the message, the full URL of the image is put into the message, instead of the shortened and attached image URL...
https://twitter.com/intent/tweet?original_referer=http%3A%2F%2Fwww.website.com%2F&text=MyText+http%3A%2F%2Fwww.website.com%2Fimg%2Fimage.png&url=www.someurl.com
Click here to see the result (no attached image, just a full image url in the message....)
When you paste in an image URL into a tweet on Twitter.com, the image URL is automatically shortened and the image is attached to the tweet, so it shows the image when you view the tweet. I'm looking for something similar with the Web Intents.
Upvotes: 30
Views: 35102
Reputation: 1326
First, you will need to post the image in a tweet to twitter.
Next, go to the tweet URL. It will be something like https://twitter.com/yourtwitterhandle/status/783356010631016448
. View the source for that page and search for pic.twitter.com
. You'll find a link to a URL that looks like pic.twitter.com/JvCvCquBlf
.
Simply add that link to the content of your web intent URL and it will display when the user posts. It won't share in the tweet preview screen, but once they click 'tweet', it will be added
Upvotes: 12
Reputation: 1588
You have to use twitter card:https://dev.twitter.com/cards/overview. make sure you use the summary card and not the photo card which has deprecated. here is how you do it:
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@tapaway" />
<meta name="twitter:title" content="bla bla" />
<meta name="twitter:description" content="bla bla" />
<meta name="twitter:image" content="http://www.tapawayapp.com/assets/images/share.png" />
<meta name="twitter:url" content="https://tapaway.parseapp.com//share.html" />
you can test yor cards here:https://cards-dev.twitter.com/validator
Upvotes: 3
Reputation: 14334
You can not attach an image, but you can use a Twitter Card.
With Twitter Cards, you can attach rich photos, videos and media experience to Tweets that drive traffic to your website.
Essentially, you need to add some metadata to your page. When Twitter sees that, it will automatically insert an image into the Tweet.
For a single photo, you would need to put this code on each page (put in your own details)
<meta name="twitter:card" content="photo" />
<meta name="twitter:site" content="@example" />
<meta name="twitter:title" content="My picture" />
<meta name="twitter:description" content="A description" />
<meta name="twitter:image" content="http://example.com/test.jpg" />
<meta name="twitter:url" content="http://example.com/mypage.html" />
Upvotes: 15