diff --git src/wp-includes/class-wp-image-editor.php src/wp-includes/class-wp-image-editor.php
index ccf43402a6..cc05c0247c 100644
|
|
abstract class WP_Image_Editor { |
240 | 240 | // Use the output mime type if present. If not, fall back to the input/initial mime type. |
241 | 241 | $mime_type = ! empty( $this->output_mime_type ) ? $this->output_mime_type : $this->mime_type; |
242 | 242 | // Get the default quality setting for the mime type. |
243 | | $default_quality = $this->get_default_quality( $mime_type ); |
| 243 | $default_quality = $this->get_default_quality(); |
244 | 244 | |
245 | 245 | if ( null === $quality ) { |
246 | 246 | /** |
… |
… |
abstract class WP_Image_Editor { |
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
300 | | * Returns the default compression quality setting for the mime type. |
| 300 | * Returns the default compression quality setting. |
301 | 301 | * |
302 | 302 | * @since 5.8.1 |
| 303 | * @since 6.1.0 Deprecated the `$mime_type` parameter. All mime types use the same default quality. |
303 | 304 | * |
304 | | * @param string $mime_type |
305 | | * @return int The default quality setting for the mime type. |
| 305 | * @param string $mime_type Deprecated. |
| 306 | * @return int The default quality setting. |
306 | 307 | */ |
307 | 308 | protected function get_default_quality( $mime_type ) { |
308 | | switch ( $mime_type ) { |
309 | | case 'image/webp': |
310 | | $quality = 86; |
311 | | break; |
312 | | case 'image/jpeg': |
313 | | default: |
314 | | $quality = $this->default_quality; |
315 | | } |
316 | | |
317 | | return $quality; |
| 309 | return $this->default_quality; |
318 | 310 | } |
319 | 311 | |
320 | 312 | /** |
diff --git tests/phpunit/tests/image/editor.php tests/phpunit/tests/image/editor.php
index c051ffec2b..524d64f228 100644
|
|
class Tests_Image_Editor extends WP_Image_UnitTestCase { |
126 | 126 | $this->assertSame( 82, $editor->get_quality(), 'Default quality setting is 82.' ); |
127 | 127 | |
128 | 128 | // Quality should change to the output format's value. |
129 | | // A PNG image will be converted to WEBP whose quialty should be 86. |
| 129 | // A PNG image will be converted to WEBP whose quality should be 82. |
130 | 130 | $editor->save(); |
131 | | $this->assertSame( 86, $editor->get_quality(), 'Output image format is WEBP. Quality setting for it should be 86.' ); |
| 131 | $this->assertSame( 82, $editor->get_quality(), 'Output image format is WEBP. Quality setting for it should be 82.' ); |
132 | 132 | |
133 | 133 | // Removing PNG to WEBP conversion on save. Quality setting should reset to the default. |
134 | 134 | $editor->reset_output_mime_type(); |
… |
… |
class Tests_Image_Editor extends WP_Image_UnitTestCase { |
150 | 150 | $this->assertSame( 56, $editor->get_quality(), 'Filtered default quality for JPEG is 56.' ); |
151 | 151 | |
152 | 152 | // Quality should change to the output format's value as filtered above. |
153 | | // A JPEG image will be converted to WEBP whose quialty should be 42. |
| 153 | // A JPEG image will be converted to WEBP whose quality should be 42. |
154 | 154 | $editor->save(); |
155 | | $this->assertSame( 42, $editor->get_quality(), 'Image conversion from JPEG to WEBP. Filtered WEBP quality shoild be 42.' ); |
| 155 | $this->assertSame( 42, $editor->get_quality(), 'Image conversion from JPEG to WEBP. Filtered WEBP quality should be 42.' ); |
156 | 156 | |
157 | 157 | // After removing the conversion the quality setting should reset to the filtered value for the original image type, JPEG. |
158 | 158 | $editor->reset_output_mime_type(); |