English 中文(简体)
法定资产倾销,并注明精度参考文件错误
原标题:Static asset dumping with png optimization references wrong files

I m 试图利用书状2和所有可能的优化方法建立一个项目。 其中之一是优化在html中使用的图像。 地名2具有一种可使用Twig模板中的选择权等方法实现这一目的的 Asset资产。 The docs are here:

问题一是,在杰夫环境中(所有资产都是通过控制器获得的)一切都行之有效,但利卡指挥系统却向档案倾销,而没有在所制造的模板中使用。

这是在倾倒资产时的产物,然后可在网站/资产上查阅。

Dumping all prod assets.
Debug mode is off.

[file+] /home/projects/dashboard/data/dashboard/app/../web/js/4a3b4dc.js
[file+] /home/projects/dashboard/data/dashboard/app/../web/css/9640074.css
[file+] /home/projects/dashboard/data/dashboard/app/../web/assetic/1d666d2.png
[file+] /home/projects/dashboard/data/dashboard/app/../web/assetic/dfaa6c9.png
[file+] /home/projects/dashboard/data/dashboard/app/../web/assetic/5f2dd31.png

当看一看这页时,这些圆顶被叫。

<img src="/assetic/ad39e3f.png">
<img src="/assetic/69fbd4a.png">
<img src="/assetic/e4a4ede.png">

然而,Cs和js确实工作。

我的专案:

# Assetic Configuration
assetic:
    debug:          %kernel.debug%
    use_controller: false
    java: /usr/bin/java
    filters:
        cssrewrite: ~
        closure:
             jar: %kernel.root_dir%/Resources/java/compiler.jar
        yui_css:
             jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
        optipng:
            apply_to: ".png$"
            level:    3
        jpegoptim:
            apply_to: ".jpe?g$"
            strip_all: true
    twig:
        functions:
            jpegoptim: { output: images/*.jpg }
            optipng: { output: images/*.png }

我的前身模板:

 <img src="{{ optipng( @KunstmaanDashboardBundle/Resources/public/images/foursquare-logo.png ) }}" style="margin-bottom: 0;" />
问题回答

我在此问题上进行了一些测试,并进行了两次可能的tw。

<!-- standard syntax: -->
{% image  img/promo/widget.autopromo.testimonial.jpg  filter= jpegoptim  output= img/*.js  %}
    <img src="{{ asset_url }}" alt="Example"/>
{% endimage %}

<!-- twig function: -->
<img src="{{ jpegoptim( img/promo/widget.autopromo.activity.jpg ) }}" />

我从以下组合开始:

assetic:
  debug:          %kernel.debug%
  use_controller: %kernel.debug%
  read_from:      %kernel.root_dir%/../web/static/
  write_to:       %kernel.root_dir%/../web/static/optimasset

  filters:
    jpegoptim:
      bin: /usr/bin/jpegoptim
      apply_to: ".jpe?g$"
      strip_all: true
  twig:
    functions:
        jpegoptim: ~

二. 变化 我拥有以下指挥权,以确保海滩清晰,新的档案被倾倒。

rm -Rvf app/cache/* # yes I wanted to make that sure cache is cleared
rm -Rvf web/static/optimasset; 
app/console cache:clear --no-warmup; 
app/console assetic:dump

www.un.org/Depts/DGACM/index_spanish.htm

00 First the dump output was

web/static/optimasset/images/e749c9f.jpg
web/static/optimasset/images/e749c9f_widget.autopromo.testimonial_1.jpg
web/static/optimasset/assetic
web/static/optimasset/assetic/bb69582.jpg
web/static/optimasset/assetic/bb69582_widget.autopromo.activity_1.jpg

和生成

<img src="/static/images/e749c9f_widget.autopromo.testimonial_1.jpg" alt="Example">
<img src="/static/assetic/c03bc54.jpg">

Note:

  • the twig function generates a wrong filename.
  • Both consider the write_to parameter in config.yml when dumping assets but still create a default folder (assetic/ or images).
  • Both ignore the write_to parameter when generating html but use their default folder following the folder specified in framework.templating.assets_base_urls.http
  • Twig function generate html with a wrong filename

www.un.org/Depts/DGACM/index_spanish.htm

<>0> Specting an输出目录 in the config.yml

filters:
    jpegoptim:
        bin: /usr/bin/jpegoptim
        apply_to: ".jpe?g$"
        strip_all: true
        output: img/*.jpg  # just a test
twig:
    functions:
        jpegoptim: {output: img/*.jpg } # according to documentation

<>说明: 你的代价完全相同。 两个辛迪加都不处理“产出”问题(只是tw)。

www.un.org/Depts/DGACM/index_spanish.htm

<>0> 具体产出:

我在产出道路上添加了<代码>optimasset/,因为这样就不考虑````'write_to''价值。

{% image  img/promo/widget.autopromo.testimonial.jpg  filter= jpegoptim  output= optimasset/img/*.jpg  %}
    <img src="{{ asset_url }}" alt="Example"/>
{% endimage %}

<img src="{{ jpegoptim( img/promo/widget.autopromo.activity.jpg , {output: optimasset/img/*.jpg }) }}" />

倾销:

web/static/optimasset/optimasset/img
web/static/optimasset/optimasset/img/974c414.jpg
web/static/optimasset/optimasset/img/974c414_widget.autopromo.testimonial_1.jpg
web/static/optimasset/optimasset/img/c230e9e.jpg
web/static/optimasset/optimasset/img/c230e9e_widget.autopromo.activity_1.jpg

成为:

<img src="/static/optimasset/img/974c414_widget.autopromo.testimonial_1.jpg" alt="Example">
<img src="/static/optimasset/img/080b62e.jpg">

Note: The rendering is correct but the dumping path is not. To fix this I had to remove the write_to parameter.

www.un.org/Depts/DGACM/index_spanish.htm

CONCLUSION

  • {{ optipng(...) }} as {{ jpegoptim(...) }} never output the good file name. Use the syntax {% images ... %}.
  • You should nt use write_to if you are using assetic to filter images {% images %} doesn t consider it when rendering html, only {% javascripts %} and {% stylesheets %} do.

页: 1 采用CSS压缩字标中的资产2 是否已经? 或许是他们重新谈论的令人厌恶的行为,这样一来就是在这个页上第4点,看上去所提到的拉皮要求(https://github.com/symfony/symfony/pull/509)。 它可以解决你的问题:p.





相关问题
Symfony 5, I can t start the server

I develop a symfony project and everything was fine. But since yesterday I can not launch the server: enter image description here The commands symfony server:start and symfony server:stop don t work ...

learning symfony 1.4 will be good when using symfony 2.0?

I know that the architecture is different in symfony 2.0 but im learning 1.4 right now. I wonder if this knowledge i gain about 1.4 will be usable for 2.0 in some extent or will it be a total waste ...

Is symfony 2.0 stable enough to use? [closed]

I wonder if Symfony 2.0 is stable enough to use? Because I ve never used Symfony before. It seems that Symfony 2 is much better than the previous version and I don t want to relearn/recode ...

your experience using symfony 2.0 [closed]

I m going to start a new project that s building web apps from scratch. I have been thinking about using symfony framework for this project. Should I start using symfony 2.0 or stick with 1.4 ? I ...

How to increase the session timeout in Symfony

I would like to know how to increase the session timeout in symfony. Is it enough to only adjust the symfony configuration settings or must I also configure anything in my php.ini file?

How stable or unstable is symfony 2.0? [closed]

Well, I know it s a preview, and I know it says that it s not yet ready for production, and yet I dare ask the question. I need to start building a pretty big application, which is planned to go live ...

热门标签