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!" />
<img src="{{ asset('../../public/images/Tux. png') }}"> <img src="{{ asset('images/basketball. jpg') }}" alt="first"/> <img style="display: block;" src="{{ asset('images/Tux. png') }}" alt="...">
You can get the current URL in Twig/Silex 2 like this: global. request. attributes. get('_route') .
This can be accomplished by creating an array of the entry years. Inside the loop that's building the array, a conditional checks if the year already exists in the array... if the year exists, a variable is set to TRUE which you can use in your conditional later down on the page. Save this answer.
Example below lets you upload files to your_project/Resources/private/uploads/images folder and serve them in twig. When it comes to serving the images, it is a bit different to classic way. You create a route to return you image as BinaryFileResponse then show it in your twig.
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
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