0

I do not understand why, but images of my bundle are not properly called because of Assetic. I try to get it with:

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

in my VisualImmersion/SiteBundle/Resources/public/css/home.css, and my image in: VisualImmersion/SiteBundle/Resources/public/images/bg-header-1.jpg

I think i use good method for assetic in my general layout:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="robots" content="follow">
        <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'/>
        <title>{% block title %} Visual Immersion - Agence de communication {% endblock %}</title>
        <meta name="description" content="Agence de communication | Développement web - Référencement SEO / Adwords - Développement mobile / tablettes - Brand design - Community Management - Evènementiel ">
        <link rel="icon" type="image/png" href="{{ asset('css/images/favicon.png') }}"/>
        {% stylesheets filter= 'cssrewrite'
            'css/stylesheets/layout.css'
            'css/stylesheets/style.css'
            'css/stylesheets/font.css'
            'css/stylesheets/responsive.css'
            'css/stylesheets/personalized-responsive.css'
            '@VisualImmersionSiteBundle/Resources/public/css/*'
        %}
            <link rel="stylesheet" type="text/css" href="{{ asset_url }}">

        {% endstylesheets %}
        {% block javascripts %}
            <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
            <script src="http://twitterjs.googlecode.com/svn/trunk/src/twitter.min.js"></script>
            <script>
                (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
                    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
                        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
                })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

                ga('create', 'UA-41814706-1', 'visual-immersion.com');
                ga('send', 'pageview');

            </script>
        {% endblock %}
    </head>

But no image...

thank you in advance for your help

Edit: My dev_config.yml

imports:
    - { resource: config.yml }

framework:
    router:
        resource: "%kernel.root_dir%/config/routing_dev.yml"
        strict_requirements: true
    profiler: { only_exceptions: false }

web_profiler:
    toolbar: true
    intercept_redirects: false

monolog:
    handlers:
        main:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: debug
        firephp:
            type:  firephp
            level: info
        chromephp:
            type:  chromephp
            level: info

assetic:
    use_controller: true
    filters:
        cssrewrite: ~

That is my 6de3e66_part_6_home_1.css:

background-image: url('../../Resources/public/images/bg-header-1.jpg');
MeursaultF
  • 209
  • 1
  • 9
  • 20

2 Answers2

0

check my answer here CSS/JS/Images from Bundle location will be always removed after composer.phar update

I explained how to use the Resources/public directory to manage asset such as images.

Community
  • 1
  • 1
tyko
  • 96
  • 4
  • Hi, I had this setup in my composing. And assets: install - symlink, I did from the start. It is only with these concerns, I decided to revive the asset command: install to be on. – MeursaultF Nov 08 '13 at 12:50
0

Ok i did some tests:

I removed cssrewrite to my config_dev.yml. that it:

imports:
    - { resource: config.yml }

framework:
    router:
        resource: "%kernel.root_dir%/config/routing_dev.yml"
        strict_requirements: true
    profiler: { only_exceptions: false }

web_profiler:
    toolbar: true
    intercept_redirects: false

monolog:
    handlers:
        main:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: debug
        firephp:
            type:  firephp
            level: info
        chromephp:
            type:  chromephp
            level: info

assetic:
    use_controller: true

i moved annotation out of cssrewrite filter in my general layout:

{% stylesheets '@VisualImmersionSiteBundle/Resources/public/css/*'  filter='cssrewrite'
    'css/stylesheets/layout.css'
    'css/stylesheets/style.css'
    'css/stylesheets/font.css'
    'css/stylesheets/responsive.css'
    'css/stylesheets/personalized-responsive.css'
%}
    <link rel="stylesheet" type="text/css" href="{{ asset_url }}">

{% endstylesheets %}

i changed asset path in my css to:

background-image: url('/bundles/visualimmersionsite/images/bg-header-1.jpg');

and it works !

But my question is: Now it's work on dev env, ok, nice. But this approach does pose problems when I pass in a production environment?

MeursaultF
  • 209
  • 1
  • 9
  • 20