<p>I think you are missing the targeting of the asset itself.</p>
<p>If you are calling an Entry's asset from a field that expects one single image you can write:</p>
<pre><code>{% set img = entry.fieldName.one() %}
&lt;img 
   src=&quot;{{ img.getUrl('thumb') }}&quot; 
   width=&quot;{{ img.getWidth('thumb') }}&quot; 
   height=&quot;{{ img.getHeight('thumb') }}&quot; /&gt;
</code></pre>
<p>If you are doing this in a for loop, or your field allows more than one image to be selected you can write:</p>
<pre><code>{% for item in entry.fieldName %}
    {% set img = item.one() %}
    &lt;img 
       src=&quot;{{ img.getUrl('thumb') }}&quot; 
       width=&quot;{{ img.getWidth('thumb') }}&quot; 
       height=&quot;{{ img.getHeight('thumb') }}&quot; /&gt;
{% endfor %}
</code></pre>

CC BY-SA 4.0
2024-01-12T19:02:02.063Z
2024-01-12T19:02:02.063Z
kelly
<p>I think @kelly is correct, and you probably don't have an image to transform. I'd add to @kelly's suggestion a conditional to check, e.g:</p>
<pre><code>{% set img = entry.fieldName.one() %}
{% if img %}
    &lt;img 
        src=&quot;{{ img.getUrl('thumb') }}&quot; 
        width=&quot;{{ img.getWidth('thumb') }}&quot; 
        height=&quot;{{ img.getHeight('thumb') }}&quot; /&gt;
{% else %}
    ! Oops! There is no image to transform!
{% endif%}
</code></pre>

CC BY-SA 4.0
2024-09-10T12:42:54.143Z
2024-09-10T12:42:54.143Z
Seth Warburton
<p>I have set transforms in admin but when I call those transforms in Twig nothing happens. 'getUrl('thumb')' shows blank in return although when calling like</p>
<pre><code> &lt;img src=&quot;{{ asset.getUrl('thumb') }}&quot;
  width=&quot;{{ asset.getWidth('thumb') }}&quot;
  height=&quot;{{ asset.getHeight('thumb') }}&quot;&gt;
</code></pre>
<p>width and height have values but url is blank.
Anyone have idea?</p>

CC BY-SA 4.0
2024-09-10T12:37:55.480Z
Try wrapping that code in a conditional to check you have an asset, I suspect you don't.
Seth Warburton
<image-transforms>
Image Transform not working
# Image Transform not working

(Asked by: username_0 on 2024-01-12)

I have set transforms in admin but when I call those transforms in Twig nothing happens. 'getUrl('thumb')' shows blank in return although when calling like
 

width and height have values but url is blank.
Anyone have idea?

**Tags:** image-transforms

> **Comments:**
> **username_1**: Try wrapping that code in a conditional to check you have an asset, I suspect you don't.  

---

## 2 answers

### Answer by username_2 on 2024-01-12. Score: 2

I think you are missing the targeting of the asset itself.
If you are calling an Entry's asset from a field that expects one single image you can write:
{% set img = entry.fieldName.one() %}


If you are doing this in a for loop, or your field allows more than one image to be selected you can write:
{% for item in entry.fieldName %}
    {% set img = item.one() %}
    
{% endfor %}


---

### Answer by username_1 on 2024-09-10. Score: 1

I think @username_2 is correct, and you probably don't have an image to transform. I'd add to @username_2's suggestion a conditional to check, e.g:
{% set img = entry.fieldName.one() %}
{% if img %}
    
{% else %}
    ! Oops! There is no image to transform!
{% endif%}


---

