The article below is what I'm trying to do, but instead of only working on <img>
tags I want this to work for references made in CSS as well, like background-image:url('someimage.jpg');
This would make optimizing the hundreds of images I have on my website far faster to do than manually doing it and more convenient.
For example from the documentation this is how it currently does it using TWIG templating engine.
{% image '@AppBundle/Resources/public/images/example.jpg'
filter='jpegoptim' output='/images/example.jpg' %}
<img src="{{ asset_url }}" alt="Example"/>
{% endimage %}
Is this possible to do with Assetic and Jpegoptim (or through some other solution)
http://symfony.com/doc/current/cookbook/assetic/jpeg_optimize.html
Your best bet, honestly, is to write a script to jpegoptim
all your existing files.
It's probably possible to do what you want by creating a new assetic filter, but if you want it to save the jpegs to a different location (what you get from using the image tag with a filter now), that little detail actually looks like it'd be quite hard. If you used a filter to find and rewrite the images in-place, then you just have a big clunky version of a script to find and optimize all your images, and it's a fair bit of work for not really much gain.