From 36463dfee8c1b33cd2084e9f5150079fb7635f3a Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Fri, 19 Nov 2021 17:54:43 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@52217 602fd350-edb4-49c9-b593-d223f7449a82 --- .../themes/twentytwentyone/inc/template-functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-content/themes/twentytwentyone/inc/template-functions.php b/src/wp-content/themes/twentytwentyone/inc/template-functions.php index 2bee7d6f95..6498c7dfa9 100644 --- a/src/wp-content/themes/twentytwentyone/inc/template-functions.php +++ b/src/wp-content/themes/twentytwentyone/inc/template-functions.php @@ -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']; }