<p>Your image input returns and array so you need to reference the first item, even if you only allowed one to be selected.</p>

<pre><code>{% set news = craft.entries.section('news').limit(3) %}
{% for news in news %}
   {% set cover = news.promotionNewsImage %}
   {% if cover|length %}
       {{ cover[0].getUrl('gtLg') }}
   {% endif %}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2015-10-30T20:01:57.263Z
That has solved my problem, only when I run it outside `<style type="text/css">@media (min-width: 1200px){.news{code}}</style>`. I thought, that neccesary markup will not affect the output. I may post my code here, but I feel like it's another question. What do you say?
Dominik Krulak
CC BY-SA 3.0
2015-10-30T21:03:45.707Z
You may need to post that separately that seems different to what you asked above.
a-am
CC BY-SA 3.0
2015-10-30T19:34:23.563Z
2015-10-30T19:34:23.563Z
a-am
<p>I've run into an unexpected situation, where ElementCriteriaModel could not be converted to string.</p>

<pre><code>{% set news = craft.entries.section('news').limit(3) %}
{% for news in news %}
    {% set cover = news.promotionNewsImage %}
    {% if cover|length %}
        {{ cover.getUrl('gtLg') }}
    {% endif %}
{% endfor %}
</code></pre>

<p>Any thoughts on that please?</p>

<assets>
How do I output image in the loop for an entry?
# How do I output image in the loop for an entry?

(Asked by: username_0 on 2015-10-30)

I've run into an unexpected situation, where ElementCriteriaModel could not be converted to string.
{% set news = craft.entries.section('news').limit(3) %}
{% for news in news %}
    {% set cover = news.promotionNewsImage %}
    {% if cover|length %}
        {{ cover.getUrl('gtLg') }}
    {% endif %}
{% endfor %}

Any thoughts on that please?

**Tags:** assets


---

## 1 answers

### Answer by username_1 on 2015-10-30. Score: 5 | Accepted answer

Your image input returns and array so you need to reference the first item, even if you only allowed one to be selected.
{% set news = craft.entries.section('news').limit(3) %}
{% for news in news %}
   {% set cover = news.promotionNewsImage %}
   {% if cover|length %}
       {{ cover[0].getUrl('gtLg') }}
   {% endif %}
{% endfor %}

> **Comments:**
> **username_0**: That has solved my problem, only when I run it outside `<style type="text/css">@media (min-width: 1200px){.news{code}}</style>`. I thought, that neccesary markup will not affect the output. I may post my code here, but I feel like it's another question. What do you say?  
> **username_1**: You may need to post that separately that seems different to what you asked above.  

---

