Skip to content

Check for existing $metadata['sizes'] to reduce PHP warnings #632

@jamesozzie

Description

@jamesozzie

Bug Description

As raised in the support forums users may encounter ... is undefined PHP warnings, possibly due to there not being image size arrays in the image metadata.

To lessen the likelihood of such errors check does $metadata['sizes'] in the webp-uploads/load.php file exist here, and if so exit early.

In this users example the error appeared as below:

Warning: Undefined array key “sizes” in /…/plugins/performance-lab/modules/images/webp-uploads/load.php on line 594

Warning: foreach() argument must be of type array|object, null given in /…/plugins/performance-lab/modules/images/webp-uploads/load.php on line 594

Screenshots

Additional Context

  • PHP Version:
  • OS: [e.g. iOS]
  • Browser: [e.g. chrome, safari]
  • Plugin Version: [e.g. 22]
  • Device: [e.g. iPhone6]

Metadata

Metadata

Labels

[Plugin] Modern Image FormatsIssues for the Modern Image Formats plugin (formerly WebP Uploads)[Plugin] Performance LabIssue relates to work in the Performance Lab Plugin only[Type] BugAn existing feature is broken

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions