diff -r 48c4eec2b7e6 -r 8c2e4d02f4ef wp/wp-includes/class-wp-image-editor.php --- a/wp/wp-includes/class-wp-image-editor.php Fri Sep 05 18:40:08 2025 +0200 +++ b/wp/wp-includes/class-wp-image-editor.php Fri Sep 05 18:52:52 2025 +0200 @@ -111,7 +111,7 @@ * If true, image will be cropped to the specified dimensions using center positions. * If an array, the image will be cropped using the array to specify the crop location: * - * @type string $0 The x crop position. Accepts 'left' 'center', or 'right'. + * @type string $0 The x crop position. Accepts 'left', 'center', or 'right'. * @type string $1 The y crop position. Accepts 'top', 'center', or 'bottom'. * } * @return true|WP_Error @@ -240,11 +240,14 @@ * Sets Image Compression quality on a 1-100% scale. * * @since 3.5.0 + * @since 6.8.0 The `$dims` parameter was added. * - * @param int $quality Compression Quality. Range: [1,100] + * @param int $quality Compression Quality. Range: [1,100] + * @param array $dims Optional. Image dimensions array with 'width' and 'height' keys. * @return true|WP_Error True if set successfully; WP_Error on failure. + */ - public function set_quality( $quality = null ) { + public function set_quality( $quality = null, $dims = array() ) { // Use the output mime type if present. If not, fall back to the input/initial mime type. $mime_type = ! empty( $this->output_mime_type ) ? $this->output_mime_type : $this->mime_type; // Get the default quality setting for the mime type. @@ -260,11 +263,18 @@ * The WP_Image_Editor::set_quality() method has priority over the filter. * * @since 3.5.0 + * @since 6.8.0 Added the size parameter. * * @param int $quality Quality level between 1 (low) and 100 (high). * @param string $mime_type Image mime type. + * @param array $size { + * Dimensions of the image. + * + * @type int $width The image width. + * @type int $height The image height. + * } */ - $quality = apply_filters( 'wp_editor_set_quality', $default_quality, $mime_type ); + $quality = apply_filters( 'wp_editor_set_quality', $default_quality, $mime_type, $dims ? $dims : $this->size ); if ( 'image/jpeg' === $mime_type ) { /** @@ -318,7 +328,6 @@ $quality = 86; break; case 'image/jpeg': - case 'image/avif': default: $quality = $this->default_quality; } @@ -366,26 +375,7 @@ $new_ext = $file_ext; } - /** - * Filters the image editor output format mapping. - * - * Enables filtering the mime type used to save images. By default, - * the mapping array is empty, so the mime type matches the source image. - * - * @see WP_Image_Editor::get_output_format() - * - * @since 5.8.0 - * - * @param string[] $output_format { - * An array of mime type mappings. Maps a source mime type to a new - * destination mime type. Default empty array. - * - * @type string ...$0 The new mime type. - * } - * @param string $filename Path to the image. - * @param string $mime_type The source image mime type. - */ - $output_format = apply_filters( 'image_editor_output_format', array(), $filename, $mime_type ); + $output_format = wp_get_image_editor_output_format( $filename, $mime_type ); if ( isset( $output_format[ $mime_type ] ) && $this->supports_mime_type( $output_format[ $mime_type ] ) @@ -443,6 +433,7 @@ * Builds an output filename based on current file, and adding proper suffix * * @since 3.5.0 + * @since 6.8.0 Passing an empty string as $suffix will now omit the suffix from the generated filename. * * @param string $suffix * @param string $dest_path @@ -450,9 +441,11 @@ * @return string filename */ public function generate_filename( $suffix = null, $dest_path = null, $extension = null ) { - // $suffix will be appended to the destination filename, just before the extension. - if ( ! $suffix ) { - $suffix = $this->get_suffix(); + // If not empty the $suffix will be appended to the destination filename, just before the extension. + if ( $suffix ) { + $suffix = '-' . $suffix; + } elseif ( '' !== $suffix ) { + $suffix = '-' . $this->get_suffix(); } $dir = pathinfo( $this->file, PATHINFO_DIRNAME ); @@ -472,7 +465,7 @@ } } - return trailingslashit( $dir ) . "{$name}-{$suffix}.{$new_ext}"; + return trailingslashit( $dir ) . "{$name}{$suffix}.{$new_ext}"; } /**