I'm using Symfony2 and assetic in an existing project and I can't figure out how to refer to images in my CSS. I've put my images in: src/Organisation/MyBundle/Resources/public/images/
After running the assets install: php app/console assets:install public
I can load them in the browser correctly: http://sitename/bundles/organisationmy/images/logo.png
However, when I try to point to them in the CSS, with: url('/bundles/organisationmy/images/logo.png')
inspecting with firebug, the url gets changed in: url('/web/bundles/organisationmy/images/logo.png') and that results in a 404.
In my main template I have:
{% stylesheets filter='yui_css' output='css/output.css'
    '@MyBundle/Resources/public/css/bootstrap.min.css'
    '@MyBundle/Resources/public/css/bootstrap-responsive.min.css'
    '@MyBundle/Resources/public/css/my.css'
 %}
And in config.yml I have:
assetic:
    debug: %kernel.debug%
    use_controller: false
    java: /usr/bin/java
    filters:
        cssrewrite: ~
        yui_css:
            jar: %kernel.root_dir%/java/yuicompressor-2.4.7.jar
        yui_js:
            jar: %kernel.root_dir%/java/yuicompressor-2.4.7.jar
In routing.yml I have:
_assetic:
    resource: .
    type: assetic
I've seen this question Symfony2 - Assetic - load images in CSS, but I don't know if and how I can use filter='cssrewrite' and filter='yui_css' at the same time, or how to solve the problem.
Basically if I could stop Symfony2 to prefix my CSS images paths with /web/ the problem would be solved. Or, does anyone know what is the proper way to solve this problem in Symfony2?
UPDATE: I've noticed that even if I put url('something.png') the CSS doesn't get updated anymore when I load the page, so I might have messed up something with command line, I've also given commands like php app/console assetic:dump -- how to go back to the normal dev style of modify CSS and reload page?
UPDATE2: I discovered that php app/console assetic:dump --watch updates the assets automatically as they change. 
In order to load images in your CSS file the path must be "bundles/(bundle name)/images/(file name)"
UPDATE
make sure you have
write_to: %kernel.root_dir%/../web 
under 
assetic: in config.yml 
and
background: url('/bundles/(bundle name)/images/prev.png') in your css
then run
php app/console assets:install web 
and
php app/console assetic:dump 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