john
john

Reputation: 1280

Assetic CSS background images not loading but have same filepath

I know this has been asked a few times before but I'm still having trouble getting my CSS background images to work with assetic.

I've read Path of assets in CSS files in Symfony 2 and all my background images are set to ../images in my CSS:

background: url(../images/icons/icon.png)

And in my twig files as:

{% stylesheets 'bundles/commondirty/css_original/c.css' filter="cssrewrite" %}
    <link href="{{ asset_url }}" rel="stylesheet" type="text/css" /> 
{% endstylesheets %}

I've tried clearing all my cache stuff with:

php app/console cache:clear --env=prod --no-debug
rm -rf app/cache/*
rm -rf app/logs/*

Then as stated in the above answer:

php app/console --env=prod assets:install web
php app/console assetic:dump --env=prod

This works locally ('app.php', 'app_dev.php', and '/'), but as soon as I upload the files to production it fails to load background images.

Both local and production CSS is as follows so I don't understand why it doesn't work?

url("../../bundles/main/images/icons/lrg_coin.png")

Permissions? Do I need to reload/clear something?

Edit

cached CSS files on dev and prod are pointing to:

url(../../bundles/main/images/icons/lrg_coin.png) when I'm guessing it needs to be ../ not ../../? How can this be changed?

Upvotes: 0

Views: 320

Answers (1)

john
john

Reputation: 1280

Ok, I figured what I was doing wrong so thought I'd post for future reference. I had use_controller set to false in my prod_config.yml which was overriding my config.yml settings (which dev_config.yml uses)

assetic:
    use_controller: false

Changing this to true and clearing/reloading everything as stated in my question solved the issue. I knew it was something simple.

Upvotes: 1

Related Questions