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

Add a makeWebpVariant option #90

Closed
khalwat opened this issue Mar 22, 2017 · 1 comment
Closed

Add a makeWebpVariant option #90

khalwat opened this issue Mar 22, 2017 · 1 comment

Comments

@khalwat
Copy link

khalwat commented Mar 22, 2017

The .webp support is awesome, but it would be super-duper awesome of there was a boolean flag in the config:

makeWebpVariant = false,

...and I could pass it in as an option in the settings array I pass into Imager when doing my existing transforms. If set, it would do the regular transform, and -also- make a .webp version of the transform, suffixed with .webp

e.g.:

{% set transformedImages = craft.imager.transformImage('woof.jpg', [
    { width: 1200, ratio: 2/1, jpegQuality: 75, webpQuality: 75 },
    { width: 1024, ratio: 2/1, jpegQuality: 75, webpQuality: 75 },
    { width: 768, ratio: 4/3, jpegQuality: 60, webpQuality: 60 },
    ],{ format: 'jpg', makeWebpVariant: true, allowUpscale: false, mode: 'crop', position: image.focusPctX ~ '% ' ~ image.focusPctY ~ '%', interlace: true }) %}

In this case it would churn out:

/imager/woof_AS2412ADSS.jpg
/imager/woof_AS2412ADSS.jpg.webp

The reason for this is the recipes for serving up .webp files automatically depend on the file being named the normal image filename with .webp tacked on the end:

Nginx: https://github.com/uhop/grunt-tight-sprite/wiki/Recipe:-serve-WebP-with-nginx-conditionally

Apache: https://gist.github.com/seeekr/2415528

This is really the "right" way to do .webp right now, imo, due to the spotty browser support, and if it's as simple as turning on a flag to have Imager make a variant of what it's transforming already—with the correct .webp suffix appended—it'd be fantastic.

@aelvan
Copy link
Owner

aelvan commented May 18, 2017

Can we agree that this is not the best way to support webp images? :)

@aelvan aelvan closed this as completed May 25, 2017
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

2 participants