I want to store full path of image (sonata media bundle) into variable in twig. Is that possible?
If I write:
{% set pic = path item.image, 'big' %}
it throws me an error: Unexpected token "name" of value "item" ("end of statement block" expected) ...
If I write:
{% set pic = item.image %}
then it works, but it stores only name of the file, not full path.
Why don't you do like this ?
{% set rendered %}{% path item.image, 'big' %}{% endset %}
....
Here is my path {{ rendered }}
There is not such a function available (there is a path()
function to generate routes). You have to create your own twig extension with this custom function. Read all about that in the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With