From 389769f2a9248cf3e6eb23c04bbfb2b4643b7f17 Mon Sep 17 00:00:00 2001 From: Nirav Sherasiya Date: Thu, 29 Jun 2023 21:53:35 +0530 Subject: [PATCH] Update filter position update the position of the filter intermediate_image_sizes_advanced from wp_create_image_subsizes function to _wp_make_subsizes function --- src/wp-admin/includes/image.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/wp-admin/includes/image.php b/src/wp-admin/includes/image.php index f937bdc2ff53d..def8d360fbf21 100644 --- a/src/wp-admin/includes/image.php +++ b/src/wp-admin/includes/image.php @@ -361,19 +361,6 @@ function wp_create_image_subsizes( $file, $attachment_id ) { $new_sizes = wp_get_registered_image_subsizes(); - /** - * Filters the image sizes automatically generated when uploading an image. - * - * @since 2.9.0 - * @since 4.4.0 Added the `$image_meta` argument. - * @since 5.3.0 Added the `$attachment_id` argument. - * - * @param array $new_sizes Associative array of image sizes to be created. - * @param array $image_meta The image meta data: width, height, file, sizes, etc. - * @param int $attachment_id The attachment post ID for the image. - */ - $new_sizes = apply_filters( 'intermediate_image_sizes_advanced', $new_sizes, $image_meta, $attachment_id ); - return _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ); } @@ -393,6 +380,20 @@ function wp_create_image_subsizes( $file, $attachment_id ) { * @return array The attachment meta data with updated `sizes` array. Includes an array of errors encountered while resizing. */ function _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ) { + + /** + * Filters the image sizes automatically generated when uploading an image. + * + * @since 2.9.0 + * @since 4.4.0 Added the `$image_meta` argument. + * @since 5.3.0 Added the `$attachment_id` argument. + * + * @param array $new_sizes Associative array of image sizes to be created. + * @param array $image_meta The image meta data: width, height, file, sizes, etc. + * @param int $attachment_id The attachment post ID for the image. + */ + $new_sizes = apply_filters( 'intermediate_image_sizes_advanced', $new_sizes, $image_meta, $attachment_id ); + if ( empty( $image_meta ) || ! is_array( $image_meta ) ) { // Not an image attachment. return array();