<p>Assuming you have an assets field with the fieldHandle <code>teamImage1</code> then the following should work.</p>

<pre><code>{% if entry.teamImage1|length %}
    {% set asset = entry.teamImage1.first() %}
    {{ asset.url }}
{% endif %}
</code></pre>

CC BY-SA 3.0
2014-12-31T18:52:50.940Z
2014-12-31T18:52:50.940Z
Douglas McDonald
<p>This is my second website I am building with craft cms and I have no prior experience with Twig.</p>

<p>I have had a particular issue with echoing image assets from a singles entry.</p>

<p>The line I copied from my previous website with craft was;</p>

<pre><code>&lt;div id="teamsimagebg" style="background-image:url({% if entry.teamImage1 | length %}{% for asset in entry.teamImage1 %}{{ asset.url }}{% endfor %}{% endif %});"&gt;&lt;/div&gt;
</code></pre>

<p>Field handles were updated correctly and yet on the template page the image is not displayed.</p>

<p>After looking into this I found the following;</p>

<pre><code>{% set asset = entry.teamImage1.first() %}

{% if asset %}
    {{ asset.url }}
{% endif %}
</code></pre>

<p>This had no effect either.</p>

CC BY-SA 3.0
2014-12-21T17:30:51.843Z
It might be to do with the way in which you're checking the asset variable. In your original version you have {% if entry.teamImage1 | length %} whereas in the new one you are just going with {% if asset %}. Have a look at this answer on checking for empty fields- http://craftcms.stackexchange.com/questions/824/test-for-empty-field
pumkincreative
CC BY-SA 3.0
2014-12-24T09:42:07.033Z
Have you tried turning on devMode & {{ dump(asset) }} in your template. See if there's actually something in your asset variable.
Steven Vandemoortele
<templating><assets><field><image><singles>
Image asset not being displayed
# Image asset not being displayed

(Asked by: username_0 on 2014-12-21)

This is my second website I am building with craft cms and I have no prior experience with Twig.
I have had a particular issue with echoing image assets from a singles entry.
The line I copied from my previous website with craft was;


Field handles were updated correctly and yet on the template page the image is not displayed.
After looking into this I found the following;
{% set asset = entry.teamImage1.first() %}

{% if asset %}
    {{ asset.url }}
{% endif %}

This had no effect either.

**Tags:** templating, assets, field, image, singles

> **Comments:**
> **username_1**: It might be to do with the way in which you're checking the asset variable. In your original version you have {% if entry.teamImage1 | length %} whereas in the new one you are just going with {% if asset %}. Have a look at this answer on checking for empty fields- http://craftcms.stackexchange.com/questions/824/test-for-empty-field  
> **username_2**: Have you tried turning on devMode & {{ dump(asset) }} in your template. See if there's actually something in your asset variable.  

---

## 1 answers

### Answer by username_3 on 2014-12-31. Score: 1

Assuming you have an assets field with the fieldHandle teamImage1 then the following should work.
{% if entry.teamImage1|length %}
    {% set asset = entry.teamImage1.first() %}
    {{ asset.url }}
{% endif %}


---

