Make WordPress Core

Changeset 54094


Ignore:
Timestamp:
09/07/2022 03:39:28 PM (4 weeks ago)
Author:
flixos90
Message:

Media: Move wp_default_image_output_mapping() filter callback to frontend scope.

While the image_editor_output_format filter is primarily used in WP Admin, it can also be executed in frontend scope, as the related WP_Image_Editor class and wp_unique_filename() function are being loaded in that scope.

Follow up to [54086].

See #55443, #56526.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/admin-filters.php

    r54086 r54094  
    3737
    3838add_filter( 'media_upload_tabs', 'update_gallery_tab' );
    39 
    40 add_filter( 'image_editor_output_format', 'wp_default_image_output_mapping' );
    4139
    4240// Admin color schemes.
  • trunk/src/wp-admin/includes/media.php

    r54086 r54094  
    38443844    }
    38453845}
    3846 
    3847 /**
    3848  * Filters the default image output mapping.
    3849  *
    3850  * With this filter callback, WebP image files will be generated for certain JPEG source files.
    3851  *
    3852  * @since 6.1.0
    3853  *
    3854  * @param array $output_mapping Map of mime type to output format.
    3855  * @retun array The adjusted default output mapping.
    3856  */
    3857 function wp_default_image_output_mapping( $output_mapping ) {
    3858     $output_mapping['image/jpeg'] = 'image/webp';
    3859     return $output_mapping;
    3860 }
  • trunk/src/wp-includes/default-filters.php

    r53846 r54094  
    633633add_filter( 'media_send_to_editor', 'image_media_send_to_editor', 10, 3 );
    634634
     635add_filter( 'image_editor_output_format', 'wp_default_image_output_mapping' );
     636
    635637// Embeds.
    636638add_action( 'rest_api_init', 'wp_oembed_register_route' );
  • trunk/src/wp-includes/media.php

    r54085 r54094  
    39063906
    39073907/**
     3908 * Filters the default image output mapping.
     3909 *
     3910 * With this filter callback, WebP image files will be generated for certain JPEG source files.
     3911 *
     3912 * @since 6.1.0
     3913 *
     3914 * @param array $output_mapping Map of mime type to output format.
     3915 * @retun array The adjusted default output mapping.
     3916 */
     3917function wp_default_image_output_mapping( $output_mapping ) {
     3918    $output_mapping['image/jpeg'] = 'image/webp';
     3919    return $output_mapping;
     3920}
     3921
     3922/**
    39083923 * Prints default Plupload arguments.
    39093924 *
Note: See TracChangeset for help on using the changeset viewer.