<p>There should actually be a <code>entities.media</code> property available in the JSON, when there are images attached to the tweet.</p>

<p>This is what works for me:</p>

<pre><code>{% set tweets = craft.twitter.get('statuses/user_timeline') %}

{% for tweet in tweets %}
    &lt;li&gt;
        &lt;p&gt;{{ tweet.text }}&lt;/p&gt;

        {% if tweet.entities.media is defined %}
            {% for item in tweet.entities.media if item.type == 'photo' %}
                &lt;img src="{{ item.media_url }}"&gt;
            {% endfor %}
        {% endif %}
    &lt;/li&gt;
{% endfor %}
</code></pre>

CC BY-SA 3.0
2016-10-17T15:58:42.537Z
Brilliant thanks Carl, this is what I was starting to get to by testing different profiles. Turns out this doesn't cover images that have come from them embedding a link (I don't think), I may revert to directly embedding the default card style it's pretty nice these days
André Goldstein
CC BY-SA 3.0
2016-10-17T16:17:03.963Z
Ahh yeah, I don’t think Twitter Cards images are available form the API.
carlcs
CC BY-SA 3.0
2016-10-18T05:44:19.660Z
Thanks André, I posted a similar question [http://craftcms.stackexchange.com/questions/17059/twitter-api-request-for-images-with-dukt-twitter] and couldn't work out how to pickup the media URLs - let us know what you ended up doing, perhaps with an example as the Plugin's docs are rather succinct.
Nutmeg
CC BY-SA 3.0
2016-10-18T06:21:30.273Z
@nutmeg the Twitter API returns all media with the `entities` property. What kind of data are you missing? Usual links to websites that are extended as Twitter Cards?
carlcs
CC BY-SA 3.0
2018-02-21T00:09:53.873Z
Has anyone else had an issue where long tweets, that include an image, are being truncated, and not showing the image?  Any help on this would be greatly appreciated. Here is an example of two tweets with the same image http://yak.la/temp/jm.png
SteveO
CC BY-SA 3.0
2018-02-21T05:18:52.200Z
I solved my issue. You must use the api parameter: tweet_mode:'extended', then call {{tweet.full_text|autoLinkTweet}}
SteveO
CC BY-SA 3.0
2018-02-21T06:27:13.100Z
@SteveO nice! Might want to post a dedicated answer for it?
carlcs
CC BY-SA 3.0
2018-04-17T04:05:45.373Z
@SteveO Do you mind sharing your code?
Nutmeg
CC BY-SA 4.0
2018-08-14T09:01:36.043Z
Where would you add the api parameter tweet_mode:'extended'?
Nutmeg
CC BY-SA 3.0
2016-10-17T15:44:51.570Z
2016-10-17T15:44:51.570Z
carlcs
<p>I'm using Dukt's very nice Twitter plugin and it's working nicely returning the most recent tweet as I want, however I cannot seem to access the tweet's image. Is this possible?</p>

<pre><code>{% set tweets = craft.twitter.get("statuses/user_timeline.json?screen_name=#{twitterHandle}&amp;count=1&amp;exclude_replies=true&amp;include_rts=true&amp;include_entities=true") %}
</code></pre>

<p>I've tried adding <code>&amp;include_entities=true</code></p>

<p>When I print out the json, I can't seem to see any media URLs. Has anyone else had any joy here? Thanks</p>

CC BY-SA 3.0
2016-10-17T15:22:41.063Z
Hmm digging around further using Twitter's test console https://dev.twitter.com/rest/tools/console seems maybe the images I'm seeing in the tweets were only coming from the client embedding a URL which was autounfurled in Twitter
André Goldstein
CC BY-SA 3.0
2018-02-08T18:38:21.370Z
Has anyone had issues with this only working sporadically? I have a feed where images show up on some tweets but not others. Any help would be greatly appreciated.
SteveO
CC BY-SA 3.0
2018-02-10T15:29:16.150Z
This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://craftcms.stackexchange.com/questions/ask). You can also [add a bounty](https://craftcms.stackexchange.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/low-quality-posts/6281)
Robin Schambach
<plugin-dukttwitter>
Is it possible to get a tweet image when using Twitter plugin
# Is it possible to get a tweet image when using Twitter plugin

(Asked by: username_0 on 2016-10-17)

I'm using Dukt's very nice Twitter plugin and it's working nicely returning the most recent tweet as I want, however I cannot seem to access the tweet's image. Is this possible?
{% set tweets = craft.twitter.get("statuses/user_timeline.json?screen_name=#{twitterHandle}&count=1&exclude_replies=true&include_rts=true&include_entities=true") %}

I've tried adding &include_entities=true
When I print out the json, I can't seem to see any media URLs. Has anyone else had any joy here? Thanks

**Tags:** plugin-dukttwitter
> **Comments:**
> **username_0**: Hmm digging around further using Twitter's test console https://dev.twitter.com/rest/tools/console seems maybe the images I'm seeing in the tweets were only coming from the client embedding a URL which was autounfurled in Twitter  
> **username_1**: Has anyone had issues with this only working sporadically? I have a feed where images show up on some tweets but not others. Any help would be greatly appreciated.  
> **username_2**: This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://craftcms.stackexchange.com/questions/ask). You can also [add a bounty](https://craftcms.stackexchange.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/low-quality-posts/6281)  

---

## 1 answers

### Answer by username_3 on 2016-10-17. Score: 4 | Accepted answer

There should actually be a entities.media property available in the JSON, when there are images attached to the tweet.
This is what works for me:
{% set tweets = craft.twitter.get('statuses/user_timeline') %}

{% for tweet in tweets %}
    
        {{ tweet.text }}

        {% if tweet.entities.media is defined %}
            {% for item in tweet.entities.media if item.type == 'photo' %}
                
            {% endfor %}
        {% endif %}
    
{% endfor %}

> **Comments:**
> **username_0**: Brilliant thanks Carl, this is what I was starting to get to by testing different profiles. Turns out this doesn't cover images that have come from them embedding a link (I don't think), I may revert to directly embedding the default card style it's pretty nice these days  
> **username_3**: Ahh yeah, I don’t think Twitter Cards images are available form the API.  
> **username_4**: Thanks André, I posted a similar question [http://craftcms.stackexchange.com/questions/17059/twitter-api-request-for-images-with-dukt-twitter] and couldn't work out how to pickup the media URLs - let us know what you ended up doing, perhaps with an example as the Plugin's docs are rather succinct.  
> **username_3**: @nutmeg the Twitter API returns all media with the `entities` property. What kind of data are you missing? Usual links to websites that are extended as Twitter Cards?  
> **username_1**: Has anyone else had an issue where long tweets, that include an image, are being truncated, and not showing the image?  Any help on this would be greatly appreciated. Here is an example of two tweets with the same image http://yak.la/temp/jm.png  
> **username_1**: I solved my issue. You must use the api parameter: tweet_mode:'extended', then call {{tweet.full_text|autoLinkTweet}}  
> **username_3**: @SteveO nice! Might want to post a dedicated answer for it?  
> **username_4**: @SteveO Do you mind sharing your code?  
> **username_4**: Where would you add the api parameter tweet_mode:'extended'?  

---

