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

Adding the option for conversion to WebP-format #62

Open
bramdeba opened this issue Dec 17, 2020 · 5 comments
Open

Adding the option for conversion to WebP-format #62

bramdeba opened this issue Dec 17, 2020 · 5 comments

Comments

@bramdeba
Copy link

The problem to solve

When uploading images to a content platform, I might want imagemagick to automatically convert them to Google's image format, WebP for faster loading times.

Proposed solution

I would love to have the option to let imagemagick convert a file to another format, preferably WebP.

Add a targetFormat-option to the imageSizes-array to allow setting a target format (jpg, webp) for automatically resizing and converting the image in one go. That way, we would be able to use 2 image sizes for the WebP-converted image, and 2 image sizes for the JPEG-original (but resized) format to use as fallback for older browsers who do not yet support WebP.

Alternatives

Perhaps it is easier to use a postprocessor? Would love someone's opinion on this.

Additional context

Trying to fit all pieces together that are (imo) necessary for turning ApostropheCMS into the best possible JS-powered digital experience platform.

@bramdeba bramdeba added the enhancement New feature or request label Dec 17, 2020
@abea abea added help wanted enhancement and removed enhancement New feature or request labels Dec 17, 2020
@boutell
Copy link
Member

boutell commented Dec 18, 2020 via email

@boutell
Copy link
Member

boutell commented Dec 18, 2020 via email

@bramdeba
Copy link
Author

bramdeba commented Dec 20, 2020

AVIF seems like a future-proof choice indeed.

We should use content negotiation. If user agent lets us know that WebP is supported, we check for the .webp-version. If not, it should fall back to JPEG/PNG.

I've been using a Wordpress plugin that does exactly this. The image URL you're using is always a jpg/png-link, but there's a PHP-script behind the link which is dynamically checking and returning the right supported format. Works great really.

The only question I'm asking myself at the moment: do we convert on upload? Or instantly when the file is request? I'm not really sure what the best (or the most scalable) solution would be.

I'm willing to spend some time on this, if the above sounds good to you?

@stepanjakl
Copy link

stepanjakl commented Apr 30, 2021

Hi,

Any update on this matter? It would be great to have WebP image format alongside others as it is slowly becoming an industry standard.

@boutell IE11 will soon be no longer supported (🎉)


This is how it can look like in the end (including native lazy loading).

<picture>
   <source srcset="./images/image.webp" type="image/webp">
   <source srcset="./images/image.png" type="image/png">
   <img alt="image" src="./images/image.png" loading="lazy">
</picture>

@boutell
Copy link
Member

boutell commented Apr 30, 2021 via email

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

No branches or pull requests

4 participants