#54464 closed defect (bug) (fixed)
Twenty Twenty-One get_attachment_image_attributes_image_attributes not checking if variable isset properly
Reported by: | wetah | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 5.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Bundled Theme | Keywords: | good-first-bug has-patch commit |
Focuses: | template | Cc: |
Description
The twenty_twenty_one_get_attachment_image_attributes
function, added to the filter wp_get_attachment_image_attributes
in inc/template-functions.php
incorrectly checks the existence of some variables in this piece of code:
<?php $meta = wp_get_attachment_metadata( $attachment->ID ); if ( $meta['width'] && $meta['height'] ) { $width = (int) $meta['width']; $height = (int) $meta['height']; }
This causes an Undefined index: width on line 460
error if the result from the function does not set any value to $meta
. I believe something like this should be enough:
<?php $meta = wp_get_attachment_metadata( $attachment->ID ); if ( isset($meta['width']) && isset($meta['height']) ) { $width = (int) $meta['width']; $height = (int) $meta['height']; }
Attachments (1)
Change History (8)
Note: See
TracTickets for help on using
tickets.
Patch created for width & height validation