Media: Remove dimension suffix from full size converted HEIC images.

Removes the dimension suffix, eg `-1000x1000` from the file name of full size images automatically converted from HEIC to JPEGs by WordPress. Introduces unit tests for the default conversion of images and customized conversion settings via the `image_editor_output_format` filter.

Follow up to [58849], [58942], [59317], [59346], [59366].

Reviewed by davidbaumwald.
Merges [59379] and [59380] to the 6.7 branch.

Props mukesh27, peterwilsoncc, azaozz, apermo, flixos90, ironprogrammer.
Fixes #62359.
See #53645, #62305.
Built from https://develop.svn.wordpress.org/branches/6.7@59381


git-svn-id: http://core.svn.wordpress.org/branches/6.7@58767 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
davidbaumwald 2024-11-11 15:46:16 +00:00
parent 7e0367b392
commit f924a35270
2 changed files with 13 additions and 1 deletions

View File

@ -341,6 +341,18 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
*/
if ( $scale_down ) {
$saved = $editor->save( $editor->generate_filename( 'scaled' ) );
} elseif ( $convert ) {
/*
* Generate a new file name for the converted image.
*
* As the image file name will be unique due to the changed file extension,
* it does not need a suffix to be unique. However, the generate_filename method
* does not allow for an empty suffix, so the "-converted" suffix is required to
* be added and subsequently removed.
*/
$converted_file_name = $editor->generate_filename( 'converted' );
$converted_file_name = preg_replace( '/(-converted\.)([a-z0-9]+)$/i', '.$2', $converted_file_name );
$saved = $editor->save( $converted_file_name );
} else {
$saved = $editor->save();
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.7-RC4-59375';
$wp_version = '6.7-RC4-59381';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.