<p>The return from <a href="https://docs.dukt.net/twitter/v2/craft-twitter.html#get-uri-query-headers-options-enablecache-cacheexpire" rel="nofollow noreferrer"><code>craft.twitter.get()</code></a> is not an array of tweets, but a response object, where the actual tweets are nested in an attribute called <code>data</code>.</p>

<p>Not tested, but from looking at the plugin docs, something like this should do it:</p>

<pre><code>{% set response = craft.twitter.get('statuses/user_timeline', { tweet_mode:'extended' }) %}

{% if response.success %}
    {% for tweet in response.data %}
        ...
    {% endfor %}
{% endif %}
</code></pre>

CC BY-SA 4.0
2018-08-17T00:16:32.053Z
Thank you for explaining, Mats. The images are showing now, albeit unlimited versions from each, per list item line. Not sure how to limit the output when a for loop includes a conditional...
Nutmeg
CC BY-SA 4.0
2018-08-17T06:56:46.380Z
@Nutmeg Not sure I follow, sorry. If you're talking about limiting the number of tweets, you could use the `count` parameter, i.e. `craft.twitter.get('statuses/user_timeline', { tweet_mode: 'extended', count: 5 })`.
Mats Mikkel Rummelhoff
CC BY-SA 4.0
2018-08-16T20:56:02.933Z
2018-08-16T20:56:02.933Z
Mats Mikkel Rummelhoff
<pre><code>{% set tweets = craft.twitter.get('statuses/user_timeline', { tweet_mode:'extended' }) %}

{% for tweet in tweets %}
    &lt;li&gt;

    {% if tweet.extended_entities.media is defined %}
        {% for item in tweet.extended_entities.media if item.type == 'photo' %}
            &lt;img src="{{ item.media_url }}"&gt;
        {% endfor %}
    {% endif %}

    &lt;/li&gt;
{% endfor %}
</code></pre>

<p>Anything obviously wrong here? I tested the API with a {{ dump(tweets) }} which seems fine.</p>

<p><a href="https://craftcms.stackexchange.com/questions/17305/is-it-possible-to-get-a-tweet-image-when-using-twitter-plugin/27302?noredirect=1#comment35764_27302">This</a> thread describes a similar issue but without a solution.</p>

<image><plugin-dukttwitter>
Problem pulling Tweets with media using Dukt's Twitter API plugin
# Problem pulling Tweets with media using Dukt's Twitter API plugin

(Asked by: username_0 on 2018-08-16)

{% set tweets = craft.twitter.get('statuses/user_timeline', { tweet_mode:'extended' }) %}

{% for tweet in tweets %}
    

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

    
{% endfor %}

Anything obviously wrong here? I tested the API with a {{ dump(tweets) }} which seems fine.
This thread describes a similar issue but without a solution.

**Tags:** image, plugin-dukttwitter


---

## 1 answers

### Answer by username_1 on 2018-08-16. Score: 2

The return from craft.twitter.get() is not an array of tweets, but a response object, where the actual tweets are nested in an attribute called data.
Not tested, but from looking at the plugin docs, something like this should do it:
{% set response = craft.twitter.get('statuses/user_timeline', { tweet_mode:'extended' }) %}

{% if response.success %}
    {% for tweet in response.data %}
        ...
    {% endfor %}
{% endif %}

> **Comments:**
> **username_0**: Thank you for explaining, Mats. The images are showing now, albeit unlimited versions from each, per list item line. Not sure how to limit the output when a for loop includes a conditional...  
> **username_1**: @username_0 Not sure I follow, sorry. If you're talking about limiting the number of tweets, you could use the `count` parameter, i.e. `craft.twitter.get('statuses/user_timeline', { tweet_mode: 'extended', count: 5 })`.  

---

