1

I'm trying to follow Symfony best practices with keeping general assets stored directly in the /web root. I am trying to set a background image in css which is not loading.

Folder Structure.

  • web
    • assets
      • css
        • style.css
      • images
        • image.jpg

I'm including the style.css file via assetic. I've installed assets with assets:install web --symlink command. I've also tried the assetic:dump command.

#div {
  background: url("../images/image.jpg");
}
{% stylesheets filter='cssrewrite'
  'assets/css/style.css'
%}
  <link rel="stylesheet" type="text/css" href="{{ asset_url }}"/>
{% endstylesheets %}
raupie
  • 169
  • 2
  • 11
  • I can't test this right now, but have you tried switching the order of the arguments in the {% stylesheets %} call? – Alec Mar 25 '16 at 02:15
  • Can be helpful [Path of assets in CSS files in Symfony 2](http://stackoverflow.com/questions/9500573/path-of-assets-in-css-files-in-symfony-2) – Max Lipsky Mar 25 '16 at 08:30
  • I did come across the link you mentioned Max, I believe they were trying to keep assets in their bundles and the images in the /web dir. I reverted back to keeping my css/js/images in my AppBundle/Resources/public and including my style.css file via assetic as 'bundles/app/css/style.css' which gets my background image path to work. I guess I should report this to symfony directly? – raupie Mar 25 '16 at 13:31

0 Answers0