1

I have the following code:

<img{{ block.imageWidth|length ? ' width="' ~ block.imageWidth ~ 'px"' }} />

If imageWidth is specified as 120, it should output:

<img width="120px" />

However it is outputting this:

<img width=&quot;120px&quot; />

I've tried using |raw but that doesn't work.

Any ideas?

Thanks

2
{# set test variable, to make your code work #}
{% set block = {imageWidth: 300} %}

{# the real output #}
<img{{ block.imageWidth|length ? (' width="' ~ block.imageWidth~ 'px"')|raw }} />

Works for me

  • Ah I was missing the bracket, thank you! – fxfuture Mar 22 at 8:40

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.