WordPress / performance

Performance plugin from the WordPress Performance Group, which is a collection of standalone performance modules.
https://wordpress.org/plugins/performance-lab/
GNU General Public License v2.0
367 stars 101 forks source link

Convert WebP to AVIF on upload #1557

Open phanduynam opened 2 months ago

phanduynam commented 2 months ago

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

mukeshpanchal27 commented 2 months ago

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

phanduynam commented 2 months ago

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

adamsilverstein commented 2 weeks ago

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.

phanduynam commented 2 weeks ago

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

mukeshpanchal27 commented 2 weeks ago

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 ),
        );
phanduynam commented 1 week ago

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