Tweet with image using JavaScript


I’m integration my web application with twitter so that use can tweet an image with the tweet. I’m following to create through javascript.
But there is now way to attach image url with the tweet.

Could you advise how to attach image url with the twee?



The web intents and web Tweet composer do not support directly uploading an image with the Tweet. You are free to use the text parameter to specify some text to pre-populate the Tweet composer with, which could be a link to an image or web page with a card, but if you want to upload an image directly, you will need to build your own app which performs media upload.


Hi Andy

Thanks for you reply.
When I use image link in twitter composer it doesn’t show the image preview in the tweet but just text of the link as you can see below.

Is there a way a preview of the image link can be shown in tweet through composer?

I have also tried LinqToTwitter library in C# to upload media which works fine but for that I have to specify ConsumerKey, ConsumerSecret, OAuthToken, OAuthTokenSecret which is for a specific user account all the time. Also through this option there is no user interface from twitter so that user can see the composer screen etc. I want to give option to the user to tweet image in his/her account through my web application and ideally if twitter can handle login flow will be great like how facebook does in the below link

Is there a way in twitter?



No there is no way to do this using Twitter web intents, you would have to build that app and have users authenticate to Twitter individually.


How can I authenticate a user using twitter login screens?


How can a preview of the image link of a tweet can be seen in that tweet?


You would sign up for a Twitter application at and configure for read-write access.

A visitor to your webpage could enter a Log in with Twitter authorization flow.

If the visitor grants access to your Twitter app to post to a Twitter account on their behalf you can create a new Tweet including media using the Twitter API.


Thanks for your reply
I have found a simple & easy way through javascript ( to add the url with tweet which will show the image preview in the tweet as below

Now one last thing I would like to select only the text but not the url in tweet screen as below

How can I achieve this?



A link preview for the shared URL may be provided via Twitter Cards markup