Can someone tell me how to do an image transform on a reference tag? I've tried

{% set images %}
<img src="{asset:123:getUrl('transform')}" />
<img src="{asset:124:getUrl('transform')}" />
{% endset %}

{{ images|parseRefs|raw }}

But this just gives back the source urls and not the crops.



I believe a Reference Tag can not perform an image transform because it doesn't return an ElementCriteriaModel object.

I worked around this by using the craft asset id parameter:

    {% set assetSearch  = craft.assets.id(12651) %}


I think you are forgetting to loop through the images. If not could you be clearer in your question?

It should work like this:

{% for image in entry.imageHandle %}
    <img src="('{{ image.getUrl('transform') }}')" width="{{ image.getWidth('transform') }}" height="{{ image.getHeight('transform') }}');">
{% endfor %}
  • Hi justin, I would like to use the reference tags. To do that I need to parse the var as explained in: link But as I don't just want the url back, I don't get how to parse the code to also do an image transfrom. Regards – Coen van der Kolk Oct 7 '16 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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