mirror of
git://develop.git.wordpress.org/
synced 2025-03-23 05:20:01 +01:00
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
This commit is contained in:
parent
8a0db56771
commit
36463dfee8
@ -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'];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user