performance icon indicating copy to clipboard operation
performance copied to clipboard

Convert WebP to AVIF on upload

Open phanduynam opened this issue 1 year ago • 2 comments

Modern Image Formats 2.2.0 does not support converting uploaded WebP files to AVIF

phanduynam avatar Sep 24 '24 02:09 phanduynam

Thanks, @phanduynam, for raising this issue.

Currently the plugin didn't added support for WebP to AVIF image but in future if possible we can add it.

cc. @adamsilverstein

mukeshpanchal27 avatar Sep 24 '24 04:09 mukeshpanchal27

@mukeshpanchal27 Thanks, I'm looking forward to this.

phanduynam avatar Sep 24 '24 04:09 phanduynam

Currently the plugin didn't added support for WebP to AVIF image but in future if possible we can add it.

This should be a relatively small change. No new UI is needed, if the selected output format is AVIF and users upload a WebP we can convert them.

@mukeshpanchal27 Thanks, I'm looking forward to this.

@phanduynam I'm curious about your use case / why you have WebP's you are trying to upload in the first place. It makes sense to "upgrade" to AVIF, but I thought most users would be coming from JPEGs.

adamsilverstein avatar Nov 06 '24 14:11 adamsilverstein

Currently the plugin didn't added support for WebP to AVIF image but in future if possible we can add it.

This should be a relatively small change. No new UI is needed, if the selected output format is AVIF and users upload a WebP we can convert them.

@mukeshpanchal27 Thanks, I'm looking forward to this.

@phanduynam I'm curious about your use case / why you have WebP's you are trying to upload in the first place. It makes sense to "upgrade" to AVIF, but I thought most users would be coming from JPEGs.

I'm doing a website crawl, there will be webp images, but I want them all converted to avif. Simple as that

phanduynam avatar Nov 07 '24 17:11 phanduynam

Currently the plugin didn't added support for WebP to AVIF image but in future if possible we can add it.

This should be a relatively small change. No new UI is needed, if the selected output format is AVIF and users upload a WebP we can convert them.

This change fix the WebP to AVIF transforms.

diff --git a/plugins/webp-uploads/helper.php b/plugins/webp-uploads/helper.php
index 7669154b..d4a5047b 100644
--- a/plugins/webp-uploads/helper.php
+++ b/plugins/webp-uploads/helper.php
@@ -28,7 +28,7 @@ function webp_uploads_get_upload_image_mime_transforms(): array {
 
        $default_transforms = array(
                'image/jpeg' => array( 'image/' . $output_format ),
-               'image/webp' => array( 'image/webp' ),
+               'image/webp' => array( 'image/' . $output_format ),
                'image/avif' => array( 'image/avif' ),
                'image/png'  => array( 'image/' . $output_format ),
        );

mukeshpanchal27 avatar Nov 11 '24 06:11 mukeshpanchal27

@adamsilverstein I would like to know if this add-on applies to the 18/11 update?

phanduynam avatar Nov 14 '24 02:11 phanduynam

This change fix the WebP to AVIF transforms.

That change makes sense @mukeshpanchal27, since the user has explicitly selected AVIF output. Can you open a PR with that change?

adamsilverstein avatar Dec 02 '24 16:12 adamsilverstein