Symfony2 Path to image in twig template

konadrian picture konadrian · May 6, 2013 · Viewed 74.3k times · Source

I store img in Acme/DemoBundle/Resources/public/img/weather_icon/blizzard.gif I want to put this img in my template so I did

<img src="{{ asset('bundles/acmedemo/img/weather_icons/blizzard.gif') }}" />

and

<img src="{{ asset('..img/weather_icons/blizzard.gif') }}"  />

and

And this did't work. I did assets:install and assetic:dump

Solved it worked

<img src="{{ asset('img/weather_icons/Blizzard.gif') }}" alt="Symfony!" />

Answer

Nisam picture Nisam · May 6, 2013

Please try this

<img src="{{ asset('bundles/acmedemo/img/weather_icons/blizzard.gif') }}" />

You should istall your assets into web directory with the command

app/console assets:install web