Monday, 15 June 2015

symfony2 - How to access Symfony image filter settings from twig -



symfony2 - How to access Symfony image filter settings from twig -

i build macro, automatically reads image's width , height of corresponding filter.

let's say, part of images.yml

liip_imagine: filter_sets: original: path: original quality: 80 small: path: little quality: 75 filters: thumbnail: { size: [400, 400], mode: inset }

how can re-use size in twig macro?

{% macro img(media, filter) %} {% spaceless %} <img src="{{ media.filename|imagine_filter(filter) }}" alt="" {# there this? #} width="{{ imagine_get_filter(filter).filters[0].size[0] }}" height="{{ imagine_get_filter(filter).filters[0].size[1] }}" /> {% endspaceless %} {% endmacro %}

symfony2 macros twig

No comments:

Post a Comment