Image asset not being displayed 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;

&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;


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.
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 %}