Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#54526 closed defect (bug) (duplicate)

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

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

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
5 years ago

  • Milestone Awaiting Review
  • Resolutionduplicate
  • Status newclosed

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

#2 @domainsupport
5 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.