I've created a section with a thumbnail image and also a dropdown to allow the user to select the transformation to apply to that image.

I've pre-created all the asset transformations ready and this is the code I have :

{% set imageTransform = storyEntry.storyThumbnailTransform %}
{% set thumbnailImage = storyEntry.storyThumbnail.first() %}
<img src="{{thumbnailImage.url(imageTransform) }}" alt="" class="post__preview-img post__preview-img--grid">

However, it doesn't appear to be rendering the image. If I output storyEntry.storyThumbnailTransform to the page, it displays the value of the image transform as expected.

What am I doing wrong? Or is there another way to accomplish this?

2 Answers 2


The imageTransform value is actually an object, representing the entire dropdown field.

Update the first line to this...

{% set imageTransform = storyEntry.storyThumbnailTransform.value %}

This will ensure that the selected value is passed on, instead of the full object.

(The reason that you see the proper value when you output it directly is because the object's __toString method is automatically being called internally.)

  • Lindsey, could this be used for custom image transforms set on the page? I'm getting the error that says that image transform is not available (and it is available if I type in verbatim). Commented Jun 16, 2017 at 17:48
  • @JohnJohnson Hard to say without looking at your code. I'd recommend asking a brand new question... feel free to link back to this thread if relevant.
    – Lindsey D
    Commented Jun 16, 2017 at 17:50
  • @LindseyD here is the question: craftcms.stackexchange.com/questions/20873/… Commented Jun 16, 2017 at 18:01

Do you not still have to do:

        {% for asset in thumbnailImage %}
            <img src="{{ asset.getUrl(imageTransform) }}" alt="" class="post__preview-img post__preview-img--grid">
        {% endfor %}
  • No need for a loop, because they've already got it narrowed down to the first thumbnail image. Also .getUrl and .url are interchangeable (url is just an alias).
    – Lindsey D
    Commented Apr 18, 2016 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.