0
votes

I have a css file and an image in a bundle directory according these paths:

My_project
+-src
 +-Project
  +-MyBundle
   +-Resources
    +-public
     +-css
      +-MyCSSfile.css
     +-images
      +-MyImage.jpeg

In my view I call my css using assetic:

{% stylesheets 'bundles/myBundle/css/MyCSSfile.css' filter='cssrewrite' %}
    <link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %}

In my CSS I use:

background-image: url('../images/background.jpg');

Obviously it doens't work. The url which is returned by symfony is: "http://localhost:8888/MY_Project/web/bundles/myBundle/css/bundles/myBundle/images/background.jpg".

Any idea? Please

2
Look a little closer at this example: symfony.com/doc/current/cookbook/assetic/…Jared Farrish
I did. Looking at the documentation is always the first thing I do. That's why I refer to the CSS files using their actual, publicly-accessible path.Karrimor88

2 Answers

1
votes

In your case, maybe you should use :

php app/console assets:install

in order to copy or symlink assets in the web/bundles directory.

0
votes

Try this

php bin/console assetic:dump 

and try also to clear your cache