0

I have following problem:

i try to load pictures with css. But they can't be found.

My css file:

.newsMenu {
    background-image: url(../gfx/bannerSeite.png);
    background-repeat: no-repeat;
    background-size: 900px;
}

my TwigTemplate which loads css:

{% stylesheets 
    'bundles/doublebeatswebsite/css/index.css'
    'bundles/doublebeatswebsite/css/jquery.mCustomScrollbar.css'
    output="bundles/doublebeatswebsite/css/compiled/main.css"
    filter="cssrewrite"
    filter="yui_css"
%}

My DirectoryStructure

+src
  +DoubleBeats
    +WebsiteBundle
      +Resources
        +public
          +css
            -index.css
            -jquery*.css
+web
  +bundles
    +doublebeatswebsite
      +css
        +compiled
          -main.css
          -main_index.css
          -main_jquery*.css
        -index.css
        -jquery*.css

Browser output; Created by cssrewrite

url("../../../../../bundles/doublebeatswebsite/gfx/*.png")

Die angegebene URL konnte nicht geladen werden

I've allready tried absolute path in the css file what also didn't work (and what i try to avoid)

url(/bundles/.../gfx/*.png)

I tried also without cssrewrite and with

background-image: url(../../gfx/bannerSeite.png);

EDIT

I just found out that also pictures i've set with {{ asset() }} are not working. It all worked before and I can't figure out what changed. I tried now to set the rights to 777 of all web files. Myabe i changed something by coincidence in the config?! You have any idea?

1
  • filter="cssrewrite,yui_css" Commented Mar 7, 2014 at 7:24

2 Answers 2

2

You might try using uglifycss: http://symfony.com/doc/current/cookbook/assetic/uglifyjs.html

I ran into trouble trying to use yui_css but had no problem using uglifycss with the instructions above.

Also I believe Yui compressor is being deprecated:

The YUI Compressor is going through a deprecation process. But don't worry! See How to Minify CSS/JS Files (using UglifyJS and UglifyCSS) for an alternative.

Source: http://symfony.com/doc/current/cookbook/assetic/yuicompressor.html

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

4 Comments

Thanks! I#m going to check it out and maybe I will switch completly! But I guess it won't solve my problem as i just found out that also pictures i've set with {{ asset() }} are not working. It all worked before and I can't figure out what changed. I tried now to set the rights to 777 of all web files. Myabe i changed something by coincidence in the config?! You have any idea?
Hope this isn't stating the obvious, but it could be worth clearing the cache, running the assets:install + assetic:dump again. I've only recently started learning all this myself and similar problems a couple of days ago.
Yeah i did this all the time. Thanks anyway!
Oh and if you choose to go with uglifycss, I found it preferable to install to the app/Resources folder directly. (See note under install instructions at the link provided)
0

Use Assetic with cssrewrite filter:

http://symfony.com/doc/2.3/cookbook/assetic/asset_management.html#fixing-css-paths-with-the-cssrewrite-filter

1 Comment

As i wrote: I'm using cssrewrite. You can see it twig.file - code

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.