From 42416cf3923d47270bd5650d9677f35f1ead1880 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Wed, 7 Sep 2022 15:41:15 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@54094 git-svn-id: http://core.svn.wordpress.org/trunk@53653 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/admin-filters.php | 2 -- wp-admin/includes/media.php | 15 --------------- wp-includes/default-filters.php | 2 ++ wp-includes/media.php | 15 +++++++++++++++ wp-includes/version.php | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/wp-admin/includes/admin-filters.php b/wp-admin/includes/admin-filters.php index f5f9600332..e80c111dde 100644 --- a/wp-admin/includes/admin-filters.php +++ b/wp-admin/includes/admin-filters.php @@ -37,8 +37,6 @@ add_filter( 'media_upload_library', 'media_upload_library' ); add_filter( 'media_upload_tabs', 'update_gallery_tab' ); -add_filter( 'image_editor_output_format', 'wp_default_image_output_mapping' ); - // Admin color schemes. add_action( 'admin_init', 'register_admin_color_schemes', 1 ); add_action( 'admin_head', 'wp_color_scheme_settings' ); diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 3e2093ac2b..51f21ddb7d 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -3843,18 +3843,3 @@ function wp_media_attach_action( $parent_id, $action = 'attach' ) { exit; } } - -/** - * Filters the default image output mapping. - * - * With this filter callback, WebP image files will be generated for certain JPEG source files. - * - * @since 6.1.0 - * - * @param array $output_mapping Map of mime type to output format. - * @retun array The adjusted default output mapping. - */ -function wp_default_image_output_mapping( $output_mapping ) { - $output_mapping['image/jpeg'] = 'image/webp'; - return $output_mapping; -} diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 4933e3f88f..ad9cef6691 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -632,6 +632,8 @@ add_action( 'media_buttons', 'media_buttons' ); add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 ); add_filter( 'media_send_to_editor', 'image_media_send_to_editor', 10, 3 ); +add_filter( 'image_editor_output_format', 'wp_default_image_output_mapping' ); + // Embeds. add_action( 'rest_api_init', 'wp_oembed_register_route' ); add_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 ); diff --git a/wp-includes/media.php b/wp-includes/media.php index e398644178..5de60501c3 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -3904,6 +3904,21 @@ function _wp_image_editor_choose( $args = array() ) { return false; } +/** + * Filters the default image output mapping. + * + * With this filter callback, WebP image files will be generated for certain JPEG source files. + * + * @since 6.1.0 + * + * @param array $output_mapping Map of mime type to output format. + * @retun array The adjusted default output mapping. + */ +function wp_default_image_output_mapping( $output_mapping ) { + $output_mapping['image/jpeg'] = 'image/webp'; + return $output_mapping; +} + /** * Prints default Plupload arguments. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 9677927709..fc61753e3b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-54093'; +$wp_version = '6.1-alpha-54094'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.