Media: Simplify file name generation for image conversions.
Use the empty string argument in `$editor->save()` added in [59855] to simplify the code used to prevent image format conversions from getting a suffix appended to their file names. Props joedolson, audrasjb, azaozz. See #62385. Fixes #63003. Built from https://develop.svn.wordpress.org/trunk@59897 git-svn-id: http://core.svn.wordpress.org/trunk@59239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -339,17 +339,8 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
|
|||||||
if ( $scale_down ) {
|
if ( $scale_down ) {
|
||||||
$saved = $editor->save( $editor->generate_filename( 'scaled' ) );
|
$saved = $editor->save( $editor->generate_filename( 'scaled' ) );
|
||||||
} elseif ( $convert ) {
|
} elseif ( $convert ) {
|
||||||
/*
|
// Pass an empty string to avoid adding a suffix to converted file names.
|
||||||
* Generate a new file name for the converted image.
|
$saved = $editor->save( $editor->generate_filename( '' ) );
|
||||||
*
|
|
||||||
* 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 {
|
} else {
|
||||||
$saved = $editor->save();
|
$saved = $editor->save();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.8-alpha-59896';
|
$wp_version = '6.8-alpha-59897';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|||||||
Reference in New Issue
Block a user