diff --git a/wp-includes/media.php b/wp-includes/media.php index d29426213e..42b3e23363 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1599,32 +1599,45 @@ function wp_image_file_matches_image_meta( $image_location, $image_meta, $attach * or false if dimensions cannot be determined. */ function wp_image_src_get_dimensions( $image_src, $image_meta, $attachment_id = 0 ) { - if ( ! wp_image_file_matches_image_meta( $image_src, $image_meta, $attachment_id ) ) { - return false; - } + $dimensions = false; // Is it a full size image? if ( strpos( $image_src, $image_meta['file'] ) !== false ) { - return array( + $dimensions = array( (int) $image_meta['width'], (int) $image_meta['height'], ); } - if ( ! empty( $image_meta['sizes'] ) ) { + if ( ! $dimensions && ! empty( $image_meta['sizes'] ) ) { $src_filename = wp_basename( $image_src ); foreach ( $image_meta['sizes'] as $image_size_data ) { if ( $src_filename === $image_size_data['file'] ) { - return array( + $dimensions = array( (int) $image_size_data['width'], (int) $image_size_data['height'], ); + + break; } } } - return false; + /** + * Filter the 'wp_image_src_get_dimensions' value. + * + * @since 5.7.0 + * + * @param array|false $dimensions Array with first element being the width + * and second element being the height, or + * false if dimensions could not be determined. + * @param string $image_src The image source file. + * @param array $image_meta The image meta data as returned by + * 'wp_get_attachment_metadata()'. + * @param int $attachment_id The image attachment ID. Default 0. + */ + return apply_filters( 'wp_image_src_get_dimensions', $dimensions, $image_src, $image_meta, $attachment_id ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index ebcac711dc..3b52bfca0b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.7-alpha-50133'; +$wp_version = '5.7-alpha-50134'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.