diff --git a/plugins/webp-uploads/helper.php b/plugins/webp-uploads/helper.php index 4628d69e21..2c11f141ca 100644 --- a/plugins/webp-uploads/helper.php +++ b/plugins/webp-uploads/helper.php @@ -17,6 +17,7 @@ * * @since 1.0.0 * @since 2.0.0 Added support for AVIF. + * @since n.e.x.t Added support for PNG. * * @return array> An array of valid mime types, where the key is the mime type and the value is the extension type. */ @@ -29,12 +30,14 @@ function webp_uploads_get_upload_image_mime_transforms(): array { 'image/jpeg' => array( 'image/' . $output_format ), 'image/webp' => array( 'image/webp' ), 'image/avif' => array( 'image/avif' ), + 'image/png' => array( 'image/' . $output_format ), ); // Check setting for whether to generate both JPEG and the modern output format. - if ( webp_uploads_is_jpeg_fallback_enabled() ) { + if ( webp_uploads_is_fallback_enabled() ) { $default_transforms = array( 'image/jpeg' => array( 'image/jpeg', 'image/' . $output_format ), + 'image/png' => array( 'image/png', 'image/' . $output_format ), 'image/' . $output_format => array( 'image/' . $output_format, 'image/jpeg' ), ); } @@ -393,17 +396,18 @@ function webp_uploads_sanitize_image_format( $image_format ): string { * @return bool True if the option is enabled, false otherwise. */ function webp_uploads_is_picture_element_enabled(): bool { - return webp_uploads_is_jpeg_fallback_enabled() && (bool) get_option( 'webp_uploads_use_picture_element', false ); + return webp_uploads_is_fallback_enabled() && (bool) get_option( 'webp_uploads_use_picture_element', false ); } /** * Checks if the `perflab_generate_webp_and_jpeg` option is enabled. * * @since 2.0.0 + * @since n.e.x.t Renamed to webp_uploads_is_fallback_enabled(). * * @return bool True if the option is enabled, false otherwise. */ -function webp_uploads_is_jpeg_fallback_enabled(): bool { +function webp_uploads_is_fallback_enabled(): bool { return (bool) get_option( 'perflab_generate_webp_and_jpeg' ); } diff --git a/plugins/webp-uploads/readme.txt b/plugins/webp-uploads/readme.txt index 97ddad2d9a..e53deb792e 100644 --- a/plugins/webp-uploads/readme.txt +++ b/plugins/webp-uploads/readme.txt @@ -13,7 +13,7 @@ Converts images to more modern formats such as WebP or AVIF during upload. This plugin adds WebP and AVIF support for media uploads within the WordPress application. By default, AVIF images will be generated if supported on the hosting server, otherwise WebP will be used as the output format. When both formats are available, the output format can be selected under `Settings > Media`. Modern images will be generated only for new uploads, pre-existing images will only converted to a modern format if images are regenerated. Images can be regenerated with a plugin like [Regenerate Thumbnails](https://wordpress.org/plugins/regenerate-thumbnails/) or via WP-CLI with the `wp media regenerate` [command](https://developer.wordpress.org/cli/commands/media/regenerate/). -By default, only modern image format sub-sizes will be generated for JPEG uploads - only the original uploaded file will still exist as a JPEG image, generated image sizes use be WebP or AVIF files. To change this behavior, there is a checkbox in `Settings > Media` "Also output JPEG" that - when checked - will result in the plugin generating both JPEG and WebP or AVIF images for every sub-size (noting again that this will only affect newly uploaded images, i.e. after making said change). +By default, only modern image format sub-sizes will be generated for JPEG or PNG uploads - only the original uploaded file will still exist as a JPEG/PNG image, generated image sizes will be WebP or AVIF files. To change this behavior, there is a checkbox in `Settings > Media` "Output fallback images" that - when checked - will result in the plugin generating both the original format as well as WebP or AVIF images for every sub-size (noting again that this will only affect newly uploaded images, i.e. after making said change). _This plugin was formerly known as WebP Uploads._ diff --git a/plugins/webp-uploads/settings.php b/plugins/webp-uploads/settings.php index 0a31b571b9..c44d6c452a 100644 --- a/plugins/webp-uploads/settings.php +++ b/plugins/webp-uploads/settings.php @@ -86,10 +86,10 @@ function webp_uploads_add_media_settings_fields(): void { return; } - // Add JPEG Output settings field. + // Add fallback image output settings field. add_settings_field( 'perflab_generate_webp_and_jpeg', - __( 'Also output JPEG', 'webp-uploads' ), + __( 'Output fallback images', 'webp-uploads' ), 'webp_uploads_generate_webp_jpeg_setting_callback', 'media', 'perflab_modern_image_format_settings', @@ -145,7 +145,7 @@ function webp_uploads_generate_avif_webp_setting_callback(): void { -

+


@@ -172,9 +172,9 @@ function webp_uploads_generate_webp_jpeg_setting_callback(): void { ?> -

+

> -

+

-

img).', 'webp-uploads' ); ?>

+

img).', 'webp-uploads' ); ?>

> -

+