Answers.Body: <p>Got a solution that is cleaner than nested for loops.</p>
  
  <pre><code>{% set myRelatedImage = entry.relatedImages.first %}
  </code></pre>
  
  <p>then I can do</p>
  
  <pre><code>&lt;img src='{{ myRelatedImage.images.first.url }}'&gt;
  </code></pre>
  
  <p>My use case was slightly different. I have a bunch of sermons entries that are related to a series entry. It's the series entry that has the image attached.</p>
  
  <p>This worked very nicely.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-25T10:39:56.413Z
Answers.LastActivityDate: 2016-02-25T10:39:56.413Z
Answers.UserDisplayName: Steven Grant
Answers.Body: <p>I am an idiot, i just misspelled things. I'm still interested to know a more efficient way to do this though?</p>
  
  <p>Corrected code:</p>
  
  <pre><code>            {% for relatedImage in entry.relatedImages %}
                  {% for images in relatedImage.image %}
                      &lt;div&gt;&lt;a href="{{ relatedImage.url }}"&gt;&lt;img src="{{ images.url }}" alt="{{ relatedImage.title }}" /&gt;&lt;/a&gt;&lt;/div&gt;
                  {% endfor %}
              {% endfor %}
  </code></pre>
  
  <p>And the debug would be <code>{{ dump(relatedImage) }}</code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-25T10:24:59.173Z
Answers.Text: I thought there'd be a more succinct way of doing this as well
Answers.UserDisplayName: Steven Grant
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-21T08:05:29.633Z
Answers.LastActivityDate: 2014-10-21T08:05:29.633Z
Answers.UserDisplayName: John
Answers.Body: <p>You could use Craft's relations API and try something like this: </p>
  
  <pre><code>{% set assets = craft.assets.relatedTo(entry.relatedEntries) %}
  </code></pre>
  
  <p>However, one thing I have noticed with this approach is that it does <strong>not</strong> return duplicate images. For example, lets say you have two related entries in your single's entries field, and each of those entries have the same image, it will only return the image once. This could be either positive or negative depending on what you want to do with the data.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-09T17:50:25.797Z
Answers.LastActivityDate: 2015-11-09T17:50:25.797Z
Answers.UserDisplayName: kcolls
Body: <p>I have a "single" entry which has a "entries" field. The related entries have a image field of the "Assets" type.</p>
  
  <p>In the template, i want to display the image from each of the related entries. I figured i could do the following</p>
  
  <pre><code>        {% for relatedImage in entry.relatedImages %}
              {% for images in relatedImage %}
                  &lt;div&gt;&lt;img src="{{ images.url }}" alt="{{ asset.title }}" /&gt;&lt;/div&gt;
              {% endfor %}
          {% endfor %}
  </code></pre>
  
  <p>Though not only does it not work, but it is probably pretty inefficient too. Whilst I'm here, how do people go about inspecting what you get from your vars? Is there a Twig/Craft equivalent to PHP's <code>var_dump('relatedImage')</code>?!</p>
  
  <p>Any ideas most welcome!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-10-20T10:53:51.807Z
Comments.Text: Ahh, answered my own question, oops. I had misspelled / put in the wrong tag name and i also found the dump tag. Have edited post to reflect.
Comments.UserDisplayName: John
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-10-20T16:41:21.520Z
Comments.Text: Hey John, glad you got it worked out! You may want to separate that info and post it as an official "answer" to this question. That would make it much easier for future readers to follow your whole process.
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-10-28T18:57:50.487Z
Comments.Text: That's exactly how I do it in my templates too, looks good to me!
Comments.UserDisplayName: darylknight
Tags: <assets><relations>
Title: Get image from related entries asset field
ThreadText: # Get image from related entries asset field
  
  (Asked by: username_0 on 2014-10-20)
  
  I have a "single" entry which has a "entries" field. The related entries have a image field of the "Assets" type.
  
  In the template, i want to display the image from each of the related entries. I figured i could do the following
  
  ```
          {% for relatedImage in entry.relatedImages %}
              {% for images in relatedImage %}
                  <div><img src="{{ images.url }}" alt="{{ asset.title }}" /></div>
              {% endfor %}
          {% endfor %}
  
  ```
  
  Though not only does it not work, but it is probably pretty inefficient too. Whilst I'm here, how do people go about inspecting what you get from your vars? Is there a Twig/Craft equivalent to PHP's `var_dump('relatedImage')`?!
  
  Any ideas most welcome!
  
  **Tags:** assets, relations
  
  > **Comments:**
  > **username_0**: Ahh, answered my own question, oops. I had misspelled / put in the wrong tag name and i also found the dump tag. Have edited post to reflect.  
  > **username_1**: Hey username_0, glad you got it worked out! You may want to separate that info and post it as an official "answer" to this question. That would make it much easier for future readers to follow your whole process.  
  > **username_2**: That's exactly how I do it in my templates too, looks good to me!  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_3 on 2016-02-25. Score: 3 | Accepted answer
  
  Got a solution that is cleaner than nested for loops.
  
  ```
  {% set myRelatedImage = entry.relatedImages.first %}
  
  ```
  
  then I can do
  
  ```
  <img src='{{ myRelatedImage.images.first.url }}'>
  
  ```
  
  My use case was slightly different. I have a bunch of sermons entries that are related to a series entry. It's the series entry that has the image attached.
  
  This worked very nicely.
  
  
  ---
  
  ### Answer by username_0 on 2014-10-21. Score: 2
  
  I am an idiot, i just misspelled things. I'm still interested to know a more efficient way to do this though?
  
  Corrected code:
  
  ```
              {% for relatedImage in entry.relatedImages %}
                  {% for images in relatedImage.image %}
                      <div><a href="{{ relatedImage.url }}"><img src="{{ images.url }}" alt="{{ relatedImage.title }}" /></a></div>
                  {% endfor %}
              {% endfor %}
  
  ```
  
  And the debug would be `{{ dump(relatedImage) }}`
  
  > **Comments:**
  > **username_3**: I thought there'd be a more succinct way of doing this as well  
  
  ---
  
  ### Answer by username_4 on 2015-11-09. Score: 0
  
  You could use Craft's relations API and try something like this:
  
  ```
  {% set assets = craft.assets.relatedTo(entry.relatedEntries) %}
  
  ```
  
  However, one thing I have noticed with this approach is that it does **not** return duplicate images. For example, lets say you have two related entries in your single's entries field, and each of those entries have the same image, it will only return the image once. This could be either positive or negative depending on what you want to do with the data.
  
  
  ---
  
  