From 707a2b7c4e10fcdef3f192615aa05ea50a0484c4 Mon Sep 17 00:00:00 2001 From: COQUARD Cyrille Date: Tue, 24 Oct 2023 14:50:29 +0200 Subject: [PATCH 01/14] Added logic to display the output --- classes/Optimization/Data/AbstractData.php | 1 + classes/Optimization/Data/CustomFolders.php | 4 ++++ classes/Optimization/Data/WP.php | 5 +++++ classes/Optimization/Process/AbstractProcess.php | 3 +++ inc/functions/admin-ui.php | 4 ++++ inc/functions/api.php | 3 ++- 6 files changed, 19 insertions(+), 1 deletion(-) diff --git a/classes/Optimization/Data/AbstractData.php b/classes/Optimization/Data/AbstractData.php index c538c3dfd..3c30b4424 100644 --- a/classes/Optimization/Data/AbstractData.php +++ b/classes/Optimization/Data/AbstractData.php @@ -25,6 +25,7 @@ abstract class AbstractData implements DataInterface { */ protected $default_optimization_data = [ 'status' => '', + 'message' => '', 'level' => false, 'sizes' => [], 'stats' => [ diff --git a/classes/Optimization/Data/CustomFolders.php b/classes/Optimization/Data/CustomFolders.php index f274b65ca..dc2cb5780 100644 --- a/classes/Optimization/Data/CustomFolders.php +++ b/classes/Optimization/Data/CustomFolders.php @@ -159,6 +159,10 @@ public function update_size_optimization_data( $size, array $data ) { $old_data['hash'] = md5_file( $file_path ); } + if ( key_exists( 'message', $data ) ) { + $old_data['message'] = $data['message']; + } + if ( ! $data['success'] ) { /** * Error. diff --git a/classes/Optimization/Data/WP.php b/classes/Optimization/Data/WP.php index 220d48916..90db43fd7 100644 --- a/classes/Optimization/Data/WP.php +++ b/classes/Optimization/Data/WP.php @@ -93,8 +93,13 @@ public function update_size_optimization_data( $size, array $data ) { 'original_size' => 0, 'optimized_size' => 0, 'percent' => 0, + 'message' => '', ], $old_data['stats'] ); + if ( key_exists( 'message', $data ) ) { + $old_data['message'] = $data['message']; + } + if ( ! $data['success'] ) { /** * Error. diff --git a/classes/Optimization/Process/AbstractProcess.php b/classes/Optimization/Process/AbstractProcess.php index bdd536668..3ff8a0355 100644 --- a/classes/Optimization/Process/AbstractProcess.php +++ b/classes/Optimization/Process/AbstractProcess.php @@ -1757,6 +1757,9 @@ public function update_size_optimization_data( $response, $size, $level ) { // Size data. $data['success'] = true; + if(property_exists($response, 'message')) { + $data['message'] = imagify_translate_api_message($response->message); + } $data['original_size'] = $response->original_size; $data['optimized_size'] = $response->new_size; } diff --git a/inc/functions/admin-ui.php b/inc/functions/admin-ui.php index 446c26763..ed7ebf5dc 100644 --- a/inc/functions/admin-ui.php +++ b/inc/functions/admin-ui.php @@ -49,6 +49,10 @@ function get_imagify_attachment_optimization_text( $process ) { $output .= $output_before . '' . __( 'New Filesize:', 'imagify' ) . ' ' . $data->get_optimized_size() . '' . $output_after; } + if ( key_exists('message', $data) ) { + $output .= $output_before . '' . $data['message'] . '' . $output_after; + } + $chart = ''; if ( ! $is_media_page ) { diff --git a/inc/functions/api.php b/inc/functions/api.php index c6f32307b..cb314120d 100755 --- a/inc/functions/api.php +++ b/inc/functions/api.php @@ -164,7 +164,7 @@ function get_imagify_max_image_size() { */ function imagify_translate_api_message( $message ) { if ( ! $message ) { - return imagify_translate_api_message( 'Unknown error occurred' ); + $message = 'Unknown error occurred'; } if ( is_wp_error( $message ) ) { @@ -199,6 +199,7 @@ function imagify_translate_api_message( $message ) { '' ), 'Your image is too big to be uploaded on our server' => __( 'Your file is too big to be uploaded on our server.', 'imagify' ), + 'Webp is less performant than original' => __( 'Webp is less performant than original', 'imagify' ), 'Our server returned an invalid response' => __( 'Our server returned an invalid response.', 'imagify' ), 'cURL isn\'t installed on the server' => __( 'cURL is not available on the server.', 'imagify' ), // API messages. From 3045ad873909f8240cd941ce420633965a4c618b Mon Sep 17 00:00:00 2001 From: COQUARD Cyrille Date: Wed, 25 Oct 2023 10:57:01 +0200 Subject: [PATCH 02/14] Fixed the issues with imagify message --- inc/classes/class-imagify-files-list-table.php | 4 ++++ inc/classes/class-imagify.php | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/inc/classes/class-imagify-files-list-table.php b/inc/classes/class-imagify-files-list-table.php index 0ca273f18..0be0e0f4b 100755 --- a/inc/classes/class-imagify-files-list-table.php +++ b/inc/classes/class-imagify-files-list-table.php @@ -612,6 +612,10 @@ public function column_optimization( $item ) { +
  • + + +
  • Date: Wed, 25 Oct 2023 10:58:11 +0200 Subject: [PATCH 03/14] Fixed phpcs --- classes/Optimization/Process/AbstractProcess.php | 4 ++-- inc/classes/class-imagify.php | 2 +- inc/functions/admin-ui.php | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/classes/Optimization/Process/AbstractProcess.php b/classes/Optimization/Process/AbstractProcess.php index 3ff8a0355..0aab78cce 100644 --- a/classes/Optimization/Process/AbstractProcess.php +++ b/classes/Optimization/Process/AbstractProcess.php @@ -1757,8 +1757,8 @@ public function update_size_optimization_data( $response, $size, $level ) { // Size data. $data['success'] = true; - if(property_exists($response, 'message')) { - $data['message'] = imagify_translate_api_message($response->message); + if ( property_exists( $response, 'message' ) ) { + $data['message'] = imagify_translate_api_message( $response->message ); } $data['original_size'] = $response->original_size; $data['optimized_size'] = $response->new_size; diff --git a/inc/classes/class-imagify.php b/inc/classes/class-imagify.php index 191669193..b7d7669dd 100644 --- a/inc/classes/class-imagify.php +++ b/inc/classes/class-imagify.php @@ -443,7 +443,7 @@ private function curl_http_call( $url, $args = [] ) { * @param string $url URL from the call. * @param array $args Arguments from the call. */ - $response = apply_filters('pre_imagify_request', null, $url, $args); + $response = apply_filters( 'pre_imagify_request', null, $url, $args ); if ( $response ) { return $response; diff --git a/inc/functions/admin-ui.php b/inc/functions/admin-ui.php index ed7ebf5dc..f729255d8 100644 --- a/inc/functions/admin-ui.php +++ b/inc/functions/admin-ui.php @@ -42,6 +42,7 @@ function get_imagify_attachment_optimization_text( $process ) { } $data = $process->get_data(); + $optimized_data = $data->get_optimization_data(); $attachment_id = $media->get_id(); $optimization_level = imagify_get_optimization_level_label( $data->get_optimization_level() ); @@ -49,8 +50,8 @@ function get_imagify_attachment_optimization_text( $process ) { $output .= $output_before . '' . __( 'New Filesize:', 'imagify' ) . ' ' . $data->get_optimized_size() . '' . $output_after; } - if ( key_exists('message', $data) ) { - $output .= $output_before . '' . $data['message'] . '' . $output_after; + if ( key_exists( 'message', $optimized_data ) ) { + $output .= $output_before . '' . __( 'Convert:', 'imagify' ) . ' ' . $optimized_data['message'] . '' . $output_after; } $chart = ''; From a1d1d147fe207d43e2249b2f4bc3be67f62f00be Mon Sep 17 00:00:00 2001 From: COQUARD Cyrille Date: Tue, 7 Nov 2023 15:13:31 +0100 Subject: [PATCH 04/14] Fixed WebP generated field --- inc/functions/admin-ui.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/functions/admin-ui.php b/inc/functions/admin-ui.php index f729255d8..9957049c9 100644 --- a/inc/functions/admin-ui.php +++ b/inc/functions/admin-ui.php @@ -94,7 +94,7 @@ function get_imagify_attachment_optimization_text( $process ) { $output .= $output_before . '' . __( 'Level:', 'imagify' ) . ' ' . $optimization_level . '' . $output_after; if ( $media->is_image() ) { - $has_webp = $process->has_webp() ? __( 'Yes', 'imagify' ) : __( 'No', 'imagify' ); + $has_webp = $process->has_webp() && ! key_exists( 'message', $optimized_data ) ? __( 'Yes', 'imagify' ) : __( 'No', 'imagify' ); $output .= $output_before . '' . __( 'WebP generated:', 'imagify' ) . ' ' . esc_html( $has_webp ) . '' . $output_after; $total_optimized_thumbnails = $data->get_optimized_sizes_count(); From 8d0cca78299f56beea16a81e912a19b2cff9be56 Mon Sep 17 00:00:00 2001 From: COQUARD Cyrille Date: Thu, 9 Nov 2023 12:08:36 +0100 Subject: [PATCH 05/14] Fixed the issue to display on the front end --- classes/Optimization/File.php | 4 ++++ classes/Optimization/Process/AbstractProcess.php | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/classes/Optimization/File.php b/classes/Optimization/File.php index 170e965f5..13ad7b590 100644 --- a/classes/Optimization/File.php +++ b/classes/Optimization/File.php @@ -530,6 +530,10 @@ public function optimize( $args = [] ) { return new \WP_Error( 'temp_file_not_found', $temp_file->get_error_message() ); } + if(property_exists($response, 'message' )) { + $args['convert'] = ''; + } + if ( 'webp' === $args['convert'] ) { $destination_path = $this->get_path_to_webp(); $this->path = $destination_path; diff --git a/classes/Optimization/Process/AbstractProcess.php b/classes/Optimization/Process/AbstractProcess.php index 0aab78cce..72c2fb1cb 100644 --- a/classes/Optimization/Process/AbstractProcess.php +++ b/classes/Optimization/Process/AbstractProcess.php @@ -656,6 +656,11 @@ public function optimize_size( $size, $optimization_level = null ) { 'non_webp_file_path' => $sizes[ $thumb_size ]['path'], // Don't use $path nor $file->get_path(), it may return the path to a temporary file. 'optimization_level' => $optimization_level, ] ); + + if(property_exists( $response, 'message' )) { + $path_is_temp = false; + } + } } } @@ -731,7 +736,7 @@ protected function compare_webp_file_size( $args ) { } // Optimization succeeded. - if ( $args['is_webp'] ) { + if (! property_exists( $args['response'], 'message' ) && $args['is_webp'] ) { /** * We just created a WebP version: * Check if it is lighter than the (maybe optimized) non-WebP file. @@ -776,7 +781,7 @@ protected function compare_webp_file_size( $args ) { $webp_size = $args['non_webp_thumb_size'] . static::WEBP_SUFFIX; $webp_file_size = $this->get_data()->get_size_data( $webp_size, 'optimized_size' ); - if ( ! $webp_file_size || $webp_file_size < $args['response']->new_size ) { + if ( property_exists( $args['response'], 'message' ) || ! $webp_file_size || $webp_file_size < $args['response']->new_size ) { // The WebP file is lighter than this one. return $args['response']; } @@ -966,7 +971,7 @@ public function delete_backup() { * Then we use the backup file to create temporary files. */ - /** + /**w * Create a temporary copy of a size file. * * @since 1.9 @@ -1788,6 +1793,8 @@ public function update_size_optimization_data( $response, $size, $level ) { */ $data = (array) apply_filters( "imagify{$_unauthorized}_file_optimization_data", $data, $response, $size, $level, $this->get_data() ); + $size = str_replace('@imagify-webp', '', $size); + // Store. $this->get_data()->update_size_optimization_data( $size, $data ); From 78338a980c349e9ecfa9bf6f801239cf4504bc98 Mon Sep 17 00:00:00 2001 From: COQUARD Cyrille Date: Thu, 9 Nov 2023 12:13:37 +0100 Subject: [PATCH 06/14] Fixed code standards --- classes/Optimization/File.php | 2 +- classes/Optimization/Process/AbstractProcess.php | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/classes/Optimization/File.php b/classes/Optimization/File.php index 13ad7b590..57820f168 100644 --- a/classes/Optimization/File.php +++ b/classes/Optimization/File.php @@ -530,7 +530,7 @@ public function optimize( $args = [] ) { return new \WP_Error( 'temp_file_not_found', $temp_file->get_error_message() ); } - if(property_exists($response, 'message' )) { + if ( property_exists( $response, 'message' ) ) { $args['convert'] = ''; } diff --git a/classes/Optimization/Process/AbstractProcess.php b/classes/Optimization/Process/AbstractProcess.php index 72c2fb1cb..ea19d2117 100644 --- a/classes/Optimization/Process/AbstractProcess.php +++ b/classes/Optimization/Process/AbstractProcess.php @@ -657,10 +657,9 @@ public function optimize_size( $size, $optimization_level = null ) { 'optimization_level' => $optimization_level, ] ); - if(property_exists( $response, 'message' )) { + if ( property_exists( $response, 'message' ) ) { $path_is_temp = false; } - } } } @@ -736,7 +735,7 @@ protected function compare_webp_file_size( $args ) { } // Optimization succeeded. - if (! property_exists( $args['response'], 'message' ) && $args['is_webp'] ) { + if ( ! property_exists( $args['response'], 'message' ) && $args['is_webp'] ) { /** * We just created a WebP version: * Check if it is lighter than the (maybe optimized) non-WebP file. @@ -1793,7 +1792,7 @@ public function update_size_optimization_data( $response, $size, $level ) { */ $data = (array) apply_filters( "imagify{$_unauthorized}_file_optimization_data", $data, $response, $size, $level, $this->get_data() ); - $size = str_replace('@imagify-webp', '', $size); + $size = str_replace( '@imagify-webp', '', $size ); // Store. $this->get_data()->update_size_optimization_data( $size, $data ); From 7156f889a48119d5d11cf474408fec454b7744ed Mon Sep 17 00:00:00 2001 From: COQUARD Cyrille Date: Thu, 9 Nov 2023 14:08:26 +0100 Subject: [PATCH 07/14] Removed fix front --- inc/functions/admin-ui.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/functions/admin-ui.php b/inc/functions/admin-ui.php index 9957049c9..f729255d8 100644 --- a/inc/functions/admin-ui.php +++ b/inc/functions/admin-ui.php @@ -94,7 +94,7 @@ function get_imagify_attachment_optimization_text( $process ) { $output .= $output_before . '' . __( 'Level:', 'imagify' ) . ' ' . $optimization_level . '' . $output_after; if ( $media->is_image() ) { - $has_webp = $process->has_webp() && ! key_exists( 'message', $optimized_data ) ? __( 'Yes', 'imagify' ) : __( 'No', 'imagify' ); + $has_webp = $process->has_webp() ? __( 'Yes', 'imagify' ) : __( 'No', 'imagify' ); $output .= $output_before . '' . __( 'WebP generated:', 'imagify' ) . ' ' . esc_html( $has_webp ) . '' . $output_after; $total_optimized_thumbnails = $data->get_optimized_sizes_count(); From 8700d8f7ddc00f7d449c2a86602fa09cd4f4963f Mon Sep 17 00:00:00 2001 From: COQUARD Cyrille Date: Thu, 9 Nov 2023 15:00:02 +0100 Subject: [PATCH 08/14] Fixed code still in debugging state --- classes/Optimization/Process/AbstractProcess.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/classes/Optimization/Process/AbstractProcess.php b/classes/Optimization/Process/AbstractProcess.php index ea19d2117..f4a5be2c7 100644 --- a/classes/Optimization/Process/AbstractProcess.php +++ b/classes/Optimization/Process/AbstractProcess.php @@ -970,7 +970,7 @@ public function delete_backup() { * Then we use the backup file to create temporary files. */ - /**w + /** * Create a temporary copy of a size file. * * @since 1.9 @@ -1792,8 +1792,9 @@ public function update_size_optimization_data( $response, $size, $level ) { */ $data = (array) apply_filters( "imagify{$_unauthorized}_file_optimization_data", $data, $response, $size, $level, $this->get_data() ); - $size = str_replace( '@imagify-webp', '', $size ); - + if ( property_exists( $response, 'message' ) ) { + $size = str_replace( '@imagify-webp', '', $size ); + } // Store. $this->get_data()->update_size_optimization_data( $size, $data ); From 7d2b7f266c44d0758fb378c1ddb3f6a2702f9fe8 Mon Sep 17 00:00:00 2001 From: COQUARD Cyrille Date: Fri, 10 Nov 2023 10:06:59 +0100 Subject: [PATCH 09/14] Fixed the tmp file --- classes/Optimization/Process/AbstractProcess.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/classes/Optimization/Process/AbstractProcess.php b/classes/Optimization/Process/AbstractProcess.php index f4a5be2c7..37b61a340 100644 --- a/classes/Optimization/Process/AbstractProcess.php +++ b/classes/Optimization/Process/AbstractProcess.php @@ -659,6 +659,10 @@ public function optimize_size( $size, $optimization_level = null ) { if ( property_exists( $response, 'message' ) ) { $path_is_temp = false; + if($path !== $sizes[ $thumb_size ]['path']) { + $this->filesystem->delete($path); + } + $path = $sizes[ $thumb_size ]['path']; } } } From b5bfa3b8fd730af690219e3b92e2d80c90870a12 Mon Sep 17 00:00:00 2001 From: COQUARD Cyrille Date: Fri, 10 Nov 2023 10:31:55 +0100 Subject: [PATCH 10/14] Fixed code standards --- classes/Optimization/Process/AbstractProcess.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/Optimization/Process/AbstractProcess.php b/classes/Optimization/Process/AbstractProcess.php index 37b61a340..e21e6da13 100644 --- a/classes/Optimization/Process/AbstractProcess.php +++ b/classes/Optimization/Process/AbstractProcess.php @@ -659,8 +659,8 @@ public function optimize_size( $size, $optimization_level = null ) { if ( property_exists( $response, 'message' ) ) { $path_is_temp = false; - if($path !== $sizes[ $thumb_size ]['path']) { - $this->filesystem->delete($path); + if ( $path !== $sizes[ $thumb_size ]['path'] ) { + $this->filesystem->delete( $path ); } $path = $sizes[ $thumb_size ]['path']; } From 04d3089f8378465d7f0d6465bc7e014892c2f901 Mon Sep 17 00:00:00 2001 From: COQUARD Cyrille Date: Fri, 10 Nov 2023 10:53:47 +0100 Subject: [PATCH 11/14] Fixed Convert property --- inc/functions/admin-ui.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/functions/admin-ui.php b/inc/functions/admin-ui.php index f729255d8..5dd5c65c9 100644 --- a/inc/functions/admin-ui.php +++ b/inc/functions/admin-ui.php @@ -50,7 +50,7 @@ function get_imagify_attachment_optimization_text( $process ) { $output .= $output_before . '' . __( 'New Filesize:', 'imagify' ) . ' ' . $data->get_optimized_size() . '' . $output_after; } - if ( key_exists( 'message', $optimized_data ) ) { + if ( key_exists( 'message', $optimized_data ) && $optimized_data['message'] ) { $output .= $output_before . '' . __( 'Convert:', 'imagify' ) . ' ' . $optimized_data['message'] . '' . $output_after; } From 28bd5187f919479a9f129961382c412bdd6390c3 Mon Sep 17 00:00:00 2001 From: COQUARD Cyrille Date: Fri, 10 Nov 2023 11:59:52 +0100 Subject: [PATCH 12/14] Added patial status --- .../Optimization/Process/AbstractProcess.php | 32 +++++++++++++++++++ .../Optimization/Process/ProcessInterface.php | 7 ++++ inc/functions/admin-ui.php | 4 +++ 3 files changed, 43 insertions(+) diff --git a/classes/Optimization/Process/AbstractProcess.php b/classes/Optimization/Process/AbstractProcess.php index e21e6da13..adce73630 100644 --- a/classes/Optimization/Process/AbstractProcess.php +++ b/classes/Optimization/Process/AbstractProcess.php @@ -1539,6 +1539,38 @@ public function has_webp() { return is_string( $data ) && strpos( $data, $needle ); } + /** + * Tell if the media has all WebP versions. + * + * @return bool + */ + public function is_full_webp() { + if ( ! $this->is_valid() ) { + return false; + } + + if ( ! $this->get_media()->is_image() ) { + return false; + } + + $data = $this->get_data()->get_optimization_data(); + + $sizes = $data['sizes']; + + if ( empty( $sizes ) ) { + return false; + } + + $keys = array_keys($sizes); + $non_webp_keys = array_values(array_filter($keys, function ($key) { + return strpos($key, static::WEBP_SUFFIX) === false; + })); + + return array_reduce($non_webp_keys, function ($is_fully, $key) use ($sizes) { + return key_exists($key. self::WEBP_SUFFIX, $sizes) && $is_fully; + }, true); + } + /** * Tell if a WebP version can be created for the given file. * Make sure the file is an image before using this method. diff --git a/classes/Optimization/Process/ProcessInterface.php b/classes/Optimization/Process/ProcessInterface.php index 09baade25..fa525647f 100644 --- a/classes/Optimization/Process/ProcessInterface.php +++ b/classes/Optimization/Process/ProcessInterface.php @@ -274,6 +274,13 @@ public function delete_webp_files( $keep_full = false ); */ public function is_size_webp( $size_name ); + /** + * Tell if the media has all WebP versions. + * + * @return bool + */ + public function is_full_webp(); + /** * Tell if the media has WebP versions. * diff --git a/inc/functions/admin-ui.php b/inc/functions/admin-ui.php index 5dd5c65c9..9d986dca7 100644 --- a/inc/functions/admin-ui.php +++ b/inc/functions/admin-ui.php @@ -95,6 +95,10 @@ function get_imagify_attachment_optimization_text( $process ) { if ( $media->is_image() ) { $has_webp = $process->has_webp() ? __( 'Yes', 'imagify' ) : __( 'No', 'imagify' ); + + if( $process->has_webp() ) { + $has_webp = $process->is_full_webp() ? __( 'Yes', 'imagify' ) : __( 'Partially', 'imagify' ); + } $output .= $output_before . '' . __( 'WebP generated:', 'imagify' ) . ' ' . esc_html( $has_webp ) . '' . $output_after; $total_optimized_thumbnails = $data->get_optimized_sizes_count(); From 8d542fe50923037f6ec0f862e19b249bec3f2fdf Mon Sep 17 00:00:00 2001 From: COQUARD Cyrille Date: Fri, 10 Nov 2023 12:00:50 +0100 Subject: [PATCH 13/14] Fixed code standards --- classes/Optimization/Process/AbstractProcess.php | 10 +++++----- inc/functions/admin-ui.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/classes/Optimization/Process/AbstractProcess.php b/classes/Optimization/Process/AbstractProcess.php index adce73630..bec0948df 100644 --- a/classes/Optimization/Process/AbstractProcess.php +++ b/classes/Optimization/Process/AbstractProcess.php @@ -1561,13 +1561,13 @@ public function is_full_webp() { return false; } - $keys = array_keys($sizes); - $non_webp_keys = array_values(array_filter($keys, function ($key) { - return strpos($key, static::WEBP_SUFFIX) === false; + $keys = array_keys( $sizes ); + $non_webp_keys = array_values(array_filter($keys, function ( $key ) { + return strpos( $key, static::WEBP_SUFFIX ) === false; })); - return array_reduce($non_webp_keys, function ($is_fully, $key) use ($sizes) { - return key_exists($key. self::WEBP_SUFFIX, $sizes) && $is_fully; + return array_reduce($non_webp_keys, function ( $is_fully, $key ) use ( $sizes ) { + return key_exists( $key . self::WEBP_SUFFIX, $sizes ) && $is_fully; }, true); } diff --git a/inc/functions/admin-ui.php b/inc/functions/admin-ui.php index 9d986dca7..372d3f5a0 100644 --- a/inc/functions/admin-ui.php +++ b/inc/functions/admin-ui.php @@ -96,7 +96,7 @@ function get_imagify_attachment_optimization_text( $process ) { if ( $media->is_image() ) { $has_webp = $process->has_webp() ? __( 'Yes', 'imagify' ) : __( 'No', 'imagify' ); - if( $process->has_webp() ) { + if ( $process->has_webp() ) { $has_webp = $process->is_full_webp() ? __( 'Yes', 'imagify' ) : __( 'Partially', 'imagify' ); } $output .= $output_before . '' . __( 'WebP generated:', 'imagify' ) . ' ' . esc_html( $has_webp ) . '' . $output_after; From b73f4aa0dc219129e5a580a98eca1cf0c1db5a7e Mon Sep 17 00:00:00 2001 From: COQUARD Cyrille Date: Mon, 13 Nov 2023 12:21:49 +0100 Subject: [PATCH 14/14] Changed message to `WebP file is larger than the original image` --- inc/functions/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/functions/api.php b/inc/functions/api.php index cb314120d..e53831340 100755 --- a/inc/functions/api.php +++ b/inc/functions/api.php @@ -199,7 +199,7 @@ function imagify_translate_api_message( $message ) { '' ), 'Your image is too big to be uploaded on our server' => __( 'Your file is too big to be uploaded on our server.', 'imagify' ), - 'Webp is less performant than original' => __( 'Webp is less performant than original', 'imagify' ), + 'Webp is less performant than original' => __( 'WebP file is larger than the original image', 'imagify' ), 'Our server returned an invalid response' => __( 'Our server returned an invalid response.', 'imagify' ), 'cURL isn\'t installed on the server' => __( 'cURL is not available on the server.', 'imagify' ), // API messages.