<p>You are looping through <code>entry.image</code> with the key <code>assets</code> but inside your loop you are trying to access the URL on <code>asset</code>. These need to be the same.</p>

<pre><code>{% for asset in entry.image %}
  &lt;img class="portfolio-images" src="{{ asset.url }}"&gt;
{% endfor %}
</code></pre>

CC BY-SA 3.0
2016-08-17T12:05:17.807Z
Have have tired various versions/combinations with no luck. What is the correct code please?
DIB
CC BY-SA 3.0
2016-08-17T12:15:59.677Z
Have you checked the fieldname is correct? Try adding `{{ entry.image|length }}` to your template and see what the result is.
Luke Pearce
CC BY-SA 3.0
2016-08-17T12:57:47.050Z
Hi Luke, Thanks but I tried that and still no luck.  The field name is correct.  I'll try adding   | length  and see how I get on.
DIB
CC BY-SA 3.0
2016-08-17T13:01:44.247Z
Do you have devMode on? Luke's answer should've done the trick unless the field name is incorrect or there is no asset.
AbbeyDesign
CC BY-SA 3.0
2016-08-17T13:07:36.033Z
When I add  {{ entry.image | length }}  I get 1 displayed on the page.  Sorry I very new to this.
DIB
CC BY-SA 3.0
2016-08-17T13:18:17.233Z
That means that there is in fact something there. Can you turn devMode on? That would give you some insight as to if there are any errors.
AbbeyDesign
CC BY-SA 3.0
2016-08-17T13:26:46.767Z
Thank you!  I figured it out, it was an error in my asset settings! I am very new to Craft and still trying to figure out what I am doing.
DIB
CC BY-SA 3.0
2016-08-17T11:14:28.830Z
2016-08-17T12:14:15.183Z
2016-08-17T12:14:15.183Z
Luke Pearce
<p>I am trying to create a portfolio site. I have set up field for image, description and  a link.</p>

<p>The description and link are being pulled through but the image is not working.  This is what I have for the images field:</p>

<pre><code>{% for assets in entry.image %}
    &lt;img class="portfolio-images" src="{{ asset.url }}"&gt;
{% endfor %}
</code></pre>

<p>This is the full entry:</p>

<pre><code>&lt;section class="portfolio-section" id="portfolio"&gt; 
    &lt;h2 id="opaque" style="color:white;"&gt;Here are a few of the projects I have been working on recently.&lt;/h2&gt;
    &lt;ul class="portfolio Grid"&gt;

        {% for entry in craft.entries.section('portfolio').limit(9) %}
            &lt;li class="portfolio-item Grid-item Grid-third"&gt;
                &lt;div class="portfolio-info"&gt;
                    &lt;h3 class="portfolio-title"&gt;{{entry.title}}&lt;/h3&gt;

                    {% for assets in entry.image %}
                        &lt;img class="portfolio-images" src="{{ asset.url }}"&gt;
                    {% endfor %}

                    {{entry.description}}
                &lt;/div&gt;

                &lt;a href="{{entry.website_link}}" target="_blank"&gt;&lt;button class="button" type="button"&gt;View website&lt;/button&gt; &lt;/a&gt;
            &lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
&lt;/section&gt;
</code></pre>

<p>Why is the text and link working but the image not?</p>

<p>Thanks!</p>

<assets>
Assets in Template
# Assets in Template

(Asked by: username_0 on 2016-08-17)

I am trying to create a portfolio site. I have set up field for image, description and  a link.
The description and link are being pulled through but the image is not working.  This is what I have for the images field:
{% for assets in entry.image %}
    
{% endfor %}

This is the full entry:
 
    Here are a few of the projects I have been working on recently.
    

        {% for entry in craft.entries.section('portfolio').limit(9) %}
            
                
                    {{entry.title}}

                    {% for assets in entry.image %}
                        
                    {% endfor %}

                    {{entry.description}}
                

                View website 
            
        {% endfor %}
    


Why is the text and link working but the image not?
Thanks!

**Tags:** assets

---

## 1 answers

### Answer by username_1 on 2016-08-17. Score: 5

You are looping through entry.image with the key assets but inside your loop you are trying to access the URL on asset. These need to be the same.
{% for asset in entry.image %}
  
{% endfor %}

> **Comments:**
> **username_0**: Have have tired various versions/combinations with no luck. What is the correct code please?  
> **username_1**: Have you checked the fieldname is correct? Try adding `{{ entry.image|length }}` to your template and see what the result is.  
> **username_0**: Hi Luke, Thanks but I tried that and still no luck.  The field name is correct.  I'll try adding   | length  and see how I get on.  
> **username_2**: Do you have devMode on? Luke's answer should've done the trick unless the field name is incorrect or there is no asset.  
> **username_0**: When I add  {{ entry.image | length }}  I get 1 displayed on the page.  Sorry I very new to this.  
> **username_2**: That means that there is in fact something there. Can you turn devMode on? That would give you some insight as to if there are any errors.  
> **username_0**: Thank you!  I figured it out, it was an error in my asset settings! I am very new to Craft and still trying to figure out what I am doing.  

---

