Hello.
I’m relatively new to Grav and currently trying to work out the twig function .derivatives()
.
Is there a way to not “print” out the result but only use it for further processing?
I wanted to use the function inside a html <picture>
element for it’s <source>
.
Thank you in advance!
@kroetenstuhl,
You can call the Grav API in Twig to suit your needs. Eg.
{% set derivatives = (page.media|first).derivatives(100, 1000, 100) %}
# The image with generated derivatives (listed in field 'alternatives')
{{ dump(derivatives)}}
# The final srcset string
{{ dump(derivatives.srcset)}}
2 Likes
Thank you so much, @anon76427325 !
Now I feel a bit dumb, of course this is the way.