Twenty Twenty-One: Prevent notice thrown in `twenty_twenty_one_get_attachment_image_attributes()`.

Calling `twenty_twenty_one_get_attachment_image_attributes()` was causing an `Undefined index: width|height` notice to be thrown when the result from `wp_get_attachment_metadata()` does not set any value to `$meta`. This change adds an `isset()` check to prevent it.

Props wetah, hasanuzzamanshamim.
Fixes #54464.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51809 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb 2021-11-19 17:56:00 +00:00
parent fac3744387
commit dc1136b94e
2 changed files with 2 additions and 2 deletions

View File

@ -457,7 +457,7 @@ function twenty_twenty_one_get_attachment_image_attributes( $attr, $attachment,
$height = (int) $size[1];
} elseif ( $attachment && is_object( $attachment ) && $attachment->ID ) {
$meta = wp_get_attachment_metadata( $attachment->ID );
if ( $meta['width'] && $meta['height'] ) {
if ( isset( $meta['width'] ) && isset( $meta['height'] ) ) {
$width = (int) $meta['width'];
$height = (int) $meta['height'];
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9-alpha-52216';
$wp_version = '5.9-alpha-52217';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.