Make WordPress Core


Ignore:
Timestamp:
11/11/2024 03:44:07 PM (3 weeks ago)
Author:
davidbaumwald
Message:

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.

Location:
branches/6.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.7

  • branches/6.7/src/wp-admin/includes/image.php

    r59367 r59381  
    342342                if ( $scale_down ) {
    343343                    $saved = $editor->save( $editor->generate_filename( 'scaled' ) );
     344                } elseif ( $convert ) {
     345                    /*
     346                     * Generate a new file name for the converted image.
     347                     *
     348                     * As the image file name will be unique due to the changed file extension,
     349                     * it does not need a suffix to be unique. However, the generate_filename method
     350                     * does not allow for an empty suffix, so the "-converted" suffix is required to
     351                     * be added and subsequently removed.
     352                     */
     353                    $converted_file_name = $editor->generate_filename( 'converted' );
     354                    $converted_file_name = preg_replace( '/(-converted\.)([a-z0-9]+)$/i', '.$2', $converted_file_name );
     355                    $saved               = $editor->save( $converted_file_name );
    344356                } else {
    345357                    $saved = $editor->save();
Note: See TracChangeset for help on using the changeset viewer.