I have an image like so:
{% image output='/images/foo.jpg' '@MyBundle/Resources/public/images/bar.jpg' %}
<img src="{{ asset(asset_url) }}" alt="Something">
{% endimage %}
now I would like to get the image dimensions and add width and height attributes like
{% image output='/images/foo.jpg' '@MyBundle/Resources/public/images/bar.jpg' %}
<img src="{{ asset(asset_url) }}" alt="Something" width="{{ asset(asset_width) }}" height="{{ asset(asset_height) }}">
{% endimage %}
Is this possible?
Best Regards
In your controller, do
Then in your twig template
The only limitation/problem with this approach is, you need to include the dynamic variables (height and width) in the output url.
Do let us know how it went
Regards,