Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#54526 closed defect (bug) (duplicate)

Twenty Twenty-One: PHP Warning when attachment meta is missing

Reported by: domainsupport's profile domainsupport Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.8.2
Component: Bundled Theme Keywords:
Focuses: Cc:

Description

When an attachment doesn’t have “width” or “height” meta (for whatever reason), the following PHP error is shown …

PHP Warning: Undefined array key "width" in /wp-content/themes/twentytwentyone/inc/template-functions.php on line 460

I think that this line in template-functions.php be changed from …

<?php
if ( $meta['width'] && $meta['height'] ) {

… to …

<?php
if ( isset($meta['width']) && $meta['width'] && isset($meta['height']) && $meta['height'] ) {

Oliver

Change History (2)

#1 @audrasjb
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hello,
This issue is already fixed in #54464, which will ship in WP 5.9.

#2 @domainsupport
3 years ago

Sorry, I did try to see if there was already a ticket. Missed that. My bad.

Note: See TracTickets for help on using tickets.