I'm trying to build a project using Symfony2 and all possible optimizations included. One of such is the optimizing of images used in the html. Symfony2 has a bundle Assetic that allows for this using e.g. optipng right from the Twig templates. The docs are here: http://symfony.com/doc/2.0/cookbook/assetic/jpeg_optimize.html
The problem i'm having is that everything works in the dev environment (where all assetic assets are served through a controller) but that the CLI command dumps to a file, not used in the rendered templates.
This is the output when dumping the assets, the files are available afterwards in /web/assetic
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
When i view the page these url's are called
<img src="/assetic/ad39e3f.png">
<img src="/assetic/69fbd4a.png">
<img src="/assetic/e4a4ede.png">
Css and js however do work.
My config file:
# 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 }
My twig template:
<img src="{{ optipng('@KunstmaanDashboardBundle/Resources/public/images/foursquare-logo.png') }}" style="margin-bottom: 0;" />