I'm using an entry field to set an image transform handle:
{% set format = block.imageCrop %}
Then I'm trying to pass that to an include:
{% include 'partials/_img' with { format: format } %}
This is the _img template:
{% do image.setTransform(format) %}
{{ tag('img', {
src: image.url,
width: image.width,
height: image.height,
srcset: image.getSrcset(['1.5x', '2x', '3x']),
alt: image.alt ? image.alt : image.title,
}) }}
This is causing this error: "Setting unknown property: craft\models\ImageTransform::label"
If I change my include to the name of a transform -- with { format: 'square' } -- it works fine.
I'm not sure what the issue is here -- is there an error in my syntax? I have other instances of this include where I do manually specify the transform, rather than using a custom field (with { format: 'square' }), so ideally, I'd like to be able to do it both ways.
block.imageCrop.one()
.