<p>You should use <code>.all()</code>, but that will give you an array of <a href="https://docs.craftcms.com/api/v3/craft-elements-asset.html#public-properties" rel="nofollow noreferrer">Assets</a>. You can't call <code>.getUrl()</code> on an array, so you'd have to loop that array:</p>

<pre><code>{% for entry in craft.entries.section('projekte').all() %}  
    &lt;a href="{{ entry.url }}"&gt;      
        {% set images = entry.startbilder.all() %}

        {% if images |length %}
            {% for image in images %}
                &lt;img src="{{ image.getUrl('medium') }}" alt="{{ image.title }}" /&gt;
            {% endfor %}
        {% endif %}
    &lt;/a&gt;        
{% endfor %}
</code></pre>

<p>If you'd want to <a href="https://docs.craftcms.com/v3/dev/eager-loading-elements.html#eager-loading-image-transform-indexes" rel="nofollow noreferrer">eager load</a> the images, this is how you'd do it:</p>

<pre><code>{% for entry in craft.entries.section('projekte').with(['startbilder']).all() %}  
    &lt;a href="{{ entry.url }}"&gt;      
        {% if entry.startbilder |length %}
            {% for image in entry.startbilder %}
                &lt;img src="{{ image.getUrl('medium') }}" alt="{{ image.title }}" /&gt;
            {% endfor %}
        {% endif %}
    &lt;/a&gt;        
{% endfor %}
</code></pre>

CC BY-SA 4.0
2020-02-20T17:52:49.703Z
hi paul, thank you very much for this detailed answer. if someone has worked with expressionengine for many years before, it is sometimes difficult to adjust to the different approach of craft. I now understand the basic error I've made… and I should always use eager loading because it is much more efficient if I use lots of transformed images, right? thanks!
Matthias
CC BY-SA 4.0
2020-02-20T17:56:57.903Z
It’s always useful, when in devMode, to use {{ dump(variable) }} to see what you’re dealing with. If it’s an array, use a for loop. If it’s an object, look it up in the class reference and see what methods or attributes you can use 
Paul
CC BY-SA 4.0
2020-02-20T08:37:35.370Z
2020-02-20T08:37:35.370Z
Paul
<p>Unfortunately I'm still very new to Craft, but I have a question to which I haven't found an answer here or in the Docs or the ones I found don't seem to work in my case. </p>

<p>I want to output all the images for each entry in this loop and I don't understand how I get the "set image = entry.startbilder" to work that way?</p>

<p>I understand that ".one()" only outputs the first image but how do I change that to output all images? changing that to ".all()" results in an error.</p>

<pre><code>{% for entry in craft.entries.section('projekte').all() %}  
    &lt;a href="{{ entry.url }}"&gt;      
        {% set image = entry.startbilder.one() %}
        {% if image %}
            &lt;img src="{{ image.getUrl('medium') }}" alt="{{ image.title }}" /&gt;
        {% endif %}
    &lt;/a&gt;        
{% endfor %}
</code></pre>

<p>thanks in advance for any help!</p>

<craft3><entry><image><loop>
how to output all images in an entry's loop
# how to output all images in an entry's loop

(Asked by: username_0 on 2020-02-19)

Unfortunately I'm still very new to Craft, but I have a question to which I haven't found an answer here or in the Docs or the ones I found don't seem to work in my case. 
I want to output all the images for each entry in this loop and I don't understand how I get the "set image = entry.startbilder" to work that way?
I understand that ".one()" only outputs the first image but how do I change that to output all images? changing that to ".all()" results in an error.
{% for entry in craft.entries.section('projekte').all() %}  
          
        {% set image = entry.startbilder.one() %}
        {% if image %}
            
        {% endif %}
            
{% endfor %}

thanks in advance for any help!

**Tags:** craft3, entry, image, loop

---

## 1 answers

### Answer by username_1 on 2020-02-20. Score: 2 | Accepted answer

You should use .all(), but that will give you an array of Assets. You can't call .getUrl() on an array, so you'd have to loop that array:
{% for entry in craft.entries.section('projekte').all() %}  
          
        {% set images = entry.startbilder.all() %}

        {% if images |length %}
            {% for image in images %}
                
            {% endfor %}
        {% endif %}
            
{% endfor %}

If you'd want to eager load the images, this is how you'd do it:
{% for entry in craft.entries.section('projekte').with(['startbilder']).all() %}  
          
        {% if entry.startbilder |length %}
            {% for image in entry.startbilder %}
                
            {% endfor %}
        {% endif %}
            
{% endfor %}

> **Comments:**
> **username_0**: hi paul, thank you very much for this detailed answer. if someone has worked with expressionengine for many years before, it is sometimes difficult to adjust to the different approach of craft. I now understand the basic error I've made… and I should always use eager loading because it is much more efficient if I use lots of transformed images, right? thanks!  
> **username_1**: It’s always useful, when in devMode, to use {{ dump(variable) }} to see what you’re dealing with. If it’s an array, use a for loop. If it’s an object, look it up in the class reference and see what methods or attributes you can use   

---

