Jack Plum Jack Plum - 1 year ago 219
Twig Question

How to replace string with variable in Twig

{% image '@AppBundle/Resources/public/images/florida.png'%}
<img src="{{ asset_url }}" alt="Example" height="200" width="200"/>
{% endimage %}

I have this code here from my twig file. I want to load an image called "florida.png from the file location:"@AppBundle/Resources/public/images/florida.png". I want to replace the "@AppBundle/Resources/public/images/florida.png" with a string variable and was wondering how I could do this? Any help would be of great assistance!

Answer Source

Is this what you're after?

<img src="{{ asset('bundles/app/images/florida.png') }}" alt="Example" height="200" width="200"/>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download