Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-12T19:02:02.063Z
Answers.LastActivityDate: 2024-01-12T19:02:02.063Z
Answers.UserDisplayName: kelly
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-10T12:42:54.143Z
Answers.LastActivityDate: 2024-09-10T12:42:54.143Z
Answers.UserDisplayName: Seth Warburton
Body: <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>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-09-10T12:37:55.480Z
Comments.Text: Try wrapping that code in a conditional to check you have an asset, I suspect you don't.
Comments.UserDisplayName: Seth Warburton
Tags: <image-transforms>
Title: Image Transform not working
ThreadText: # 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
  
  ```
   <img src="{{ asset.getUrl('thumb') }}"
    width="{{ asset.getWidth('thumb') }}"
    height="{{ asset.getHeight('thumb') }}">
  
  ```
  
  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() %}
  <img 
     src="{{ img.getUrl('thumb') }}" 
     width="{{ img.getWidth('thumb') }}" 
     height="{{ img.getHeight('thumb') }}" />
  
  ```
  
  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() %}
      <img 
         src="{{ img.getUrl('thumb') }}" 
         width="{{ img.getWidth('thumb') }}" 
         height="{{ img.getHeight('thumb') }}" />
  {% 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 %}
      <img 
          src="{{ img.getUrl('thumb') }}" 
          width="{{ img.getWidth('thumb') }}" 
          height="{{ img.getHeight('thumb') }}" />
  {% else %}
      ! Oops! There is no image to transform!
  {% endif%}
  
  ```
  
  
  ---
  
  