From bd870d997cddc09dcd0ebc319356c86950606cb6 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 2 Feb 2021 17:08:48 +0000 Subject: [PATCH] Media: Move `wp_getimagesize()` to `wp-includes/media.php`, for consistency with other media functions. Follow-up to [50146]. See #49889. git-svn-id: https://develop.svn.wordpress.org/trunk@50148 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 33 -------------------------------- src/wp-includes/media.php | 36 ++++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index a8c4747c39..5935f781fb 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -7866,36 +7866,3 @@ function is_php_version_compatible( $required ) { function wp_fuzzy_number_match( $expected, $actual, $precision = 1 ) { return abs( (float) $expected - (float) $actual ) <= $precision; } - -/** - * Allows PHP's getimagesize() to be debuggable when necessary. - * - * @since 5.7.0 - * - * @param string $filename The file path. - * @param array $imageinfo Extended image information, passed by reference. - * @return array|false Array of image information or false on failure. - */ -function wp_getimagesize( $filename, &$imageinfo = array() ) { - if ( - // Skip when running unit tests. - ! defined( 'DIR_TESTDATA' ) - && - // Return without silencing errors when in debug mode. - defined( 'WP_DEBUG' ) && WP_DEBUG - ) { - return getimagesize( $filename, $imageinfo ); - } - - /** - * Silencing notice and warning is intentional. - * - * getimagesize() has a tendency to generate errors, such as "corrupt JPEG data: 7191 extraneous bytes before - * marker", even when it's able to provide image size information. - * - * See https://core.trac.wordpress.org/ticket/42480 - * - * phpcs:ignore WordPress.PHP.NoSilencedErrors - */ - return @getimagesize( $filename, $imageinfo ); -} diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index cf3a9d9f31..093e7bc4ff 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -1628,7 +1628,7 @@ function wp_image_src_get_dimensions( $image_src, $image_meta, $attachment_id = } /** - * Filter the 'wp_image_src_get_dimensions' value. + * Filters the 'wp_image_src_get_dimensions' value. * * @since 5.7.0 * @@ -4962,3 +4962,37 @@ function wp_show_heic_upload_error( $plupload_settings ) { $plupload_settings['heic_upload_error'] = true; return $plupload_settings; } + +/** + * Allows PHP's getimagesize() to be debuggable when necessary. + * + * @since 5.7.0 + * + * @param string $filename The file path. + * @param array $imageinfo Extended image information, passed by reference. + * @return array|false Array of image information or false on failure. + */ +function wp_getimagesize( $filename, &$imageinfo = array() ) { + if ( + // Skip when running unit tests. + ! defined( 'DIR_TESTDATA' ) + && + // Return without silencing errors when in debug mode. + defined( 'WP_DEBUG' ) && WP_DEBUG + ) { + return getimagesize( $filename, $imageinfo ); + } + + /* + * Silencing notice and warning is intentional. + * + * getimagesize() has a tendency to generate errors, such as + * "corrupt JPEG data: 7191 extraneous bytes before marker", + * even when it's able to provide image size information. + * + * See https://core.trac.wordpress.org/ticket/42480 + * + * phpcs:ignore WordPress.PHP.NoSilencedErrors + */ + return @getimagesize( $filename, $imageinfo ); +}