Reputation: 2936
I am trying to render an image in a Twig template like this:
<img src="{{ asset('bundles/mybundle/images/no-image.png') }}" alt="no image available" />
It is being rendered like this (with a leading slash):
<img src="/bundles/mybundle/images/no-image.png" alt="no image available" />
which causes the server to look for an image in http://myserver.com/bundles/mybundle/images/no-image.png
The problem is when I am viewing the page in dev mode, it doesn't generate the correct asset url. What it should be is:
<img src="bundles/mybundle/images/no-image.png" alt="no image available" />
which would cause the server to look in the correct location:
http://myserver.com/app_dev.php/bundles/mybundle/images/no-image.png
Is there some way around this issue? I want the images in dev mode to run through app_dev.php
Upvotes: 0
Views: 889
Reputation: 41934
Assetic uses PHP to combine, minify and modify the assets. In development, these assets can change continue, you don't want to execute the dump command each time you changed something. That's why Assetic has a use_controller
setting so assetic combines, minifies and modifies the files at request time and then returns the response as a correct CSS or JS file.
With normal assets, like images, JS files, CSS files, etc., there is nothing dynamic to run. The browser should simply request the images from the server, where they are stored. So this shouldn't go via the framework.
Upvotes: 1