Skip to content

Optimize images using jpegoptim or other optimizer #56

Open
@Ziiweb

Description

@Ziiweb

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions