Symfony2 - Assetic - load images in CSS

后端 未结 9 1979
逝去的感伤
逝去的感伤 2020-11-29 17:38

I have a CoreBundle that contains main css files and images. Now I have a problem when I load an image from css; the image isn\'t shown.

 background-image:ur         


        
相关标签:
9条回答
  • 2020-11-29 18:13

    I have developed a small bundle with a extra filter to solve this issue. You can find it on github: https://github.com/fkrauthan/FkrCssURLRewriteBundle.git

    With this bundle the @Notation for assetic works if you have relativ paths in your css file.

    0 讨论(0)
  • 2020-11-29 18:14

    I solved the problem by following the instructions on this site: http://www.craftitonline.com/2011/06/symfony2-beautify-with-assetic-and-a-template-part-ii/

    The actual problem is that you reference your bundle resources absolute, but must reference them relative.

    {% stylesheets filter='cssrewrite' output='css/*.css'
        'bundles/blistercarerisikobewertung/css/*'  %}
        <link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
    {% endstylesheets %}
    

    Clear your cache and install your assets again

    0 讨论(0)
  • 2020-11-29 18:19

    I solved this issue by permanently creating 'images' folder with images inside in 'symfony_root/web/' folder. Result: 'symfony_root/web/images/' - and it becomes work great!

    0 讨论(0)
提交回复
热议问题