<p>In the example code above, the query is retrieving a list of Entries and setting it to the variable <code>entries</code>.  Then, you are trying to loop through those Entries and treat them like they are a list of Assets.</p>

<p>As noted in the comments, this was complicating the situation.</p>

<p>It appears that, on the <code>entry.html</code> page, the <code>entry</code> variable was already available, as Craft makes that <code>entry</code> variable to all individual entry pages in Sections that have URLs.</p>

<p>This makes accessing the Assets field on that page as simple as accessing a field, rather than needing to create a separate query to find the data.  From the comments above, the solution was to just access the appropriate Assets field on the Entry Page template and loop through them:</p>

<pre><code>{% for asset in entry.entryFieldHandle %}
    &lt;img src="{{ asset.url }}"&gt;
{% endfor %}
</code></pre>

CC BY-SA 3.0
2015-08-23T05:32:54.027Z
2015-08-23T05:32:54.027Z
Ben Parizek
<p>I have a Structure section (<code>galeriesPhotos</code>) with two Entry Types:</p>

<ul>
<li><strong>Albums</strong> - the categories on the index.html page</li>
<li><strong>Photos</strong> - the the actual gallery on the <code>entry.html</code></li>
</ul>

<p>I'm trying to display the images related to the "Albums" on <code>entry.html</code> like this:</p>

<pre><code>{% set entries = craft.entries.section('galeriesPhotos').getEntryType('Photos') %}

{% for image in entries %}
  &lt;img src="{{ image.getUrl }}"&gt;
{% endfor %}
</code></pre>

<p>Nothing happens. I get a blank page without any errors. What I am doing wrong?</p>

CC BY-SA 3.0
2015-01-16T09:53:56.137Z
I think the for loop is incorrect, try changing {% for image in entries %} to {% for entry in entries %} and then change the img src to {{ entry.image.first().url }} Also if you switch on dev mode in the config it will help debug your templates.
pumkincreative
CC BY-SA 3.0
2015-01-16T09:55:36.883Z
Just tried that and it's not working
jjem
CC BY-SA 3.0
2015-01-16T10:02:57.103Z
It actually gives only the path to where the images are (<img src="http://www.example.com/gallery/2014/friday/") instead of the actual images that are uploaded in structure... Your suggestions give an error. Sorry
jjem
CC BY-SA 3.0
2015-01-16T10:13:50.767Z
Impossible to access an attribute ("url") on a NULL variable ("")
jjem
CC BY-SA 3.0
2015-01-16T10:21:16.113Z
OK sorry and thanks I entered the correct fieldHandle. It shows one image twice instead of all images that are related to this page. I guess I miss a relatedTo setting.
jjem
CC BY-SA 3.0
2015-01-16T10:51:38.017Z
Have a look at the Templating section on this page - http://buildwithcraft.com/docs/assets-fields
pumkincreative
CC BY-SA 3.0
2015-01-16T12:09:14.013Z
Thanks. I was looking way too far. This made it: `code`{% for asset in entry.entryFieldHandle %}
        <img src="{{ asset.url }}">
    {% endfor %}`code`
jjem
CC BY-SA 3.0
2015-01-16T12:32:49.630Z
Well done. Suggest you post your working code as an answer and tidy up the comments.
pumkincreative
<structure><entry-type><image>
Display images from Structure
# Display images from Structure

(Asked by: username_0 on 2015-01-16)

I have a Structure section (galeriesPhotos) with two Entry Types:

Albums - the categories on the index.html page
Photos - the the actual gallery on the entry.html

I'm trying to display the images related to the "Albums" on entry.html like this:
{% set entries = craft.entries.section('galeriesPhotos').getEntryType('Photos') %}

{% for image in entries %}
  
{% endfor %}

Nothing happens. I get a blank page without any errors. What I am doing wrong?

**Tags:** structure, entry-type, image

> **Comments:**
> **username_1**: I think the for loop is incorrect, try changing {% for image in entries %} to {% for entry in entries %} and then change the img src to {{ entry.image.first().url }} Also if you switch on dev mode in the config it will help debug your templates.  
> **username_0**: Just tried that and it's not working  
> **username_0**: It actually gives only the path to where the images are (<img src="http://www.example.com/gallery/2014/friday/") instead of the actual images that are uploaded in structure... Your suggestions give an error. Sorry  
> **username_0**: Impossible to access an attribute ("url") on a NULL variable ("")  
> **username_0**: OK sorry and thanks I entered the correct fieldHandle. It shows one image twice instead of all images that are related to this page. I guess I miss a relatedTo setting.  
> **username_1**: Have a look at the Templating section on this page - http://buildwithcraft.com/docs/assets-fields  
> **username_0**: Thanks. I was looking way too far. This made it: `code`{% for asset in entry.entryFieldHandle %}         <img src="{{ asset.url }}">     {% endfor %}`code`  
> **username_1**: Well done. Suggest you post your working code as an answer and tidy up the comments.  

---

## 1 answers

### Answer by username_2 on 2015-08-23. Score: 2

In the example code above, the query is retrieving a list of Entries and setting it to the variable entries.  Then, you are trying to loop through those Entries and treat them like they are a list of Assets.
As noted in the comments, this was complicating the situation.
It appears that, on the entry.html page, the entry variable was already available, as Craft makes that entry variable to all individual entry pages in Sections that have URLs.
This makes accessing the Assets field on that page as simple as accessing a field, rather than needing to create a separate query to find the data.  From the comments above, the solution was to just access the appropriate Assets field on the Entry Page template and loop through them:
{% for asset in entry.entryFieldHandle %}
    
{% endfor %}


---

