Symfony2 – Assetic – load images in CSS

use the cssrewrite filter from Assetic bundle

In config.yml:

assetic:
    debug:          %kernel.debug%
    use_controller: false
    filters:
        cssrewrite: ~

And then call your stylesheets like this:

 {% stylesheets 'bundles/cmtcore/css/*' filter="cssrewrite" %}
        <link rel="stylesheet" type="text/css" media="screen" href="https://stackoverflow.com/questions/7044631/{{ asset_url }}" />
 {% endstylesheets %}

Oh and don’t forget to use php app/console assetic:dump

Leave a Comment