Media: Sanity check image meta in 'wp_image_src_get_dimensions'.

This fixes a potential illegal offset error introduced in [50134] if the `$image_meta` doesn't include a `file` key.
    
Props dd32.
Fixes #51865.

Built from https://develop.svn.wordpress.org/trunk@50136


git-svn-id: http://core.svn.wordpress.org/trunk@49815 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Joe McGill 2021-02-02 04:27:06 +00:00
parent 7a8a7fdcd4
commit 2642a446b3
2 changed files with 5 additions and 2 deletions

View File

@ -1602,7 +1602,10 @@ function wp_image_src_get_dimensions( $image_src, $image_meta, $attachment_id =
$dimensions = false; $dimensions = false;
// Is it a full size image? // Is it a full size image?
if ( strpos( $image_src, $image_meta['file'] ) !== false ) { if (
isset( $image_meta['file'] ) &&
strpos( $image_src, $image_meta['file'] ) !== false
) {
$dimensions = array( $dimensions = array(
(int) $image_meta['width'], (int) $image_meta['width'],
(int) $image_meta['height'], (int) $image_meta['height'],

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.7-alpha-50135'; $wp_version = '5.7-alpha-50136';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.