Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-20T17:52:49.703Z
Answers.Text: 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!
Answers.UserDisplayName: Matthias
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-20T17:56:57.903Z
Answers.Text: 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 
Answers.UserDisplayName: Paul
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-20T08:37:35.370Z
Answers.LastActivityDate: 2020-02-20T08:37:35.370Z
Answers.UserDisplayName: Paul
Body: <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>
  
Tags: <craft3><entry><image><loop>
Title: how to output all images in an entry's loop
ThreadText: # 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() %}  
      <a href="{{ entry.url }}">      
          {% set image = entry.startbilder.one() %}
          {% if image %}
              <img src="{{ image.getUrl('medium') }}" alt="{{ image.title }}" />
          {% endif %}
      </a>        
  {% 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](https://docs.craftcms.com/api/v3/craft-elements-asset.html#public-properties). You can't call `.getUrl()` on an array, so you'd have to loop that array:
  
  ```
  {% for entry in craft.entries.section('projekte').all() %}  
      <a href="{{ entry.url }}">      
          {% set images = entry.startbilder.all() %}
  
          {% if images |length %}
              {% for image in images %}
                  <img src="{{ image.getUrl('medium') }}" alt="{{ image.title }}" />
              {% endfor %}
          {% endif %}
      </a>        
  {% endfor %}
  
  ```
  
  If you'd want to [eager load](https://docs.craftcms.com/v3/dev/eager-loading-elements.html#eager-loading-image-transform-indexes) the images, this is how you'd do it:
  
  ```
  {% for entry in craft.entries.section('projekte').with(['startbilder']).all() %}  
      <a href="{{ entry.url }}">      
          {% if entry.startbilder |length %}
              {% for image in entry.startbilder %}
                  <img src="{{ image.getUrl('medium') }}" alt="{{ image.title }}" />
              {% endfor %}
          {% endif %}
      </a>        
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: hi username_1, 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   
  
  ---
  
  