Make WordPress Core


Ignore:
Timestamp:
05/22/2021 12:58:46 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Media: Some documentation and test improvements for the image_editor_output_format filter:

  • Update the filter DocBlock per the documentation standards.
  • Use a shorter variable name for consistency with the surrounding code.
  • Delete the test file before performing assertions to avoid leftovers in case the test fails.

Follow-up to [50943].

See #52867.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-image-editor.php

    r50943 r50951  
    323323         * the mapping array is empty, so the mime type matches the source image.
    324324         *
    325          * @see src/wp-includes/class-wp-image-editor.php -> get_output_format()
     325         * @see WP_Image_Editor::get_output_format()
    326326         *
    327327         * @since 5.8.0
    328328         *
    329          * @param array $wp_image_editor_output_format {
     329         * @param array $output_format {
    330330         *     An array of mime type mappings. Maps a source mime type to a new
    331          *     destination mime type. Empty by default.
     331         *     destination mime type. Default empty array.
    332332         *
    333333         *     @type array $mime_type The source mime type {
    334334         *         @type string $mime_type The new mime type.
    335335         *     }
    336          * @param string $filename Path to the image.
     336         * @param string $filename  Path to the image.
    337337         * @param string $mime_type The source image mime type.
    338338         * }
    339339         */
    340         $wp_image_editor_output_format = apply_filters( 'image_editor_output_format', array(), $filename, $mime_type );
    341 
    342         if (
    343             isset( $wp_image_editor_output_format[ $mime_type ] ) &&
    344             $this->supports_mime_type( $wp_image_editor_output_format[ $mime_type ] )
     340        $output_format = apply_filters( 'image_editor_output_format', array(), $filename, $mime_type );
     341
     342        if ( isset( $output_format[ $mime_type ] )
     343            && $this->supports_mime_type( $output_format[ $mime_type ] )
    345344        ) {
    346             $mime_type = $wp_image_editor_output_format[ $mime_type ];
    347             $new_ext = $this->get_extension( $mime_type );
     345            $mime_type = $output_format[ $mime_type ];
     346            $new_ext   = $this->get_extension( $mime_type );
    348347        }
    349348
Note: See TracChangeset for help on using the changeset viewer.