0

我不明白为什么,但由于 Assetic,我的包的图像没有被正确调用。我尝试通过以下方式获得它:

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

在我的 VisualImmersion/SiteBundle/Resources/public/css/home.css 中,我的图像在:VisualImmersion/SiteBundle/Resources/public/images/bg-header-1.jpg

我认为我在我的总体布局中对资产使用了很好的方法:

<!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>

但是没有图...

预先感谢您的帮助

编辑:我的 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: ~

那是我的 6de3e66_part_6_home_1.css:

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

2 回答 2

0

在 composer.phar 更新后,将始终删除来自 Bundle 位置的 CSS/JS/Images此处的答案

我解释了如何使用 Resources/public 目录来管理图像等资产。

于 2013-11-08T12:31:50.353 回答
0

好的,我做了一些测试:

我将 cssrewrite 删除到我的 config_dev.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

我在我的总体布局中将注释从 cssrewrite 过滤器中移出:

{% 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 %}

我将我的 CSS 中的资产路径更改为:

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

它有效!

但我的问题是:现在它可以在 dev env 上工作,好的,很好。但是当我通过生产环境时,这种方法确实会带来问题吗?

于 2013-11-08T16:11:09.710 回答