0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks it solve my problem, but I don't understand exactly what it does

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.