Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize images using jpegoptim or other optimizer #56

Open
Ziiweb opened this issue Apr 16, 2014 · 2 comments
Open

Optimize images using jpegoptim or other optimizer #56

Ziiweb opened this issue Apr 16, 2014 · 2 comments

Comments

@Ziiweb
Copy link

Ziiweb commented Apr 16, 2014

Hi,

I'm interested in optimizing my rendered images using a kind of optimizer like jpegoptim.

I have thought in using assetic filters like here:

<img src="{{ jpegoptim('@AcmeFooBundle/Resources/public/images/example.jpg') }}" alt="Example"/>

but that syntax is colliding with ImagineBundle syntax:

<img src="{{ image(...

Well, I say "colliding" because I have tried this:

    <img  src="{{ jpegoptim(" {{ image('images/' ~ producto.imageName).scaleResize(null, 450) }} ") }}" />

and I get this:

An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "_assetic_768aa82" as such route does not exist.")

I have been thinking in creating a custom filter that includes the jpegoptim optimization process, and that could be concatenate to the rest of the filters:

scaleResize(null, 450).MyOptimFilter

Any advice to get image optimization using in the same time ImagineBundle filters?

@ozahorulia
Copy link

You can't run assetic filters with dynamic data within, because assetic works before the twig interpreter starts (it's something like preprocessor in C).

@Gregwar
Copy link
Owner

Gregwar commented Sep 27, 2014

What's exactly the interrest of jpegoptim in your case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants