You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Somehow $dimensions['width'] is 0. Fixing the symptom would be to just make sure that $dimensions['width'] > 0. I wonder if it is actually false here and it is being cast to 0. I wonder if instead of checking isset() if we should rather be checking ! empty() in this method.
The value for $dimensions['height'] is most likely coming from here:
So perhaps wp_getimagesize() is returning a bad value?
westonruter
changed the title
Improve checks for image dimensions extraction to avoid warrnings
Improve checks for image dimensions extraction to avoid warnings
Mar 10, 2022
Bug Description
As per this support topic User seeing a warning while extracting a dimension of an image.
PHP Warning: Division by zero in /wp-content/plugins/amp/includes/sanitizers/class-amp-img-sanitizer.php on line 299
I am not able to reproduce the issue at my end by I think it might be unsupported image type or corrupted image, which returned
0
orfalse
As suggested by Weston we should replace
isset()
checks withempty()
to avoid warning and apply fallback dimensions instead.Expected Behaviour
Should not show any warrning
Screenshots
No response
PHP Version
7.4
Plugin Version
2.2.1
AMP plugin template mode
Reader
WordPress Version
5.9.1
Site Health
Site health : https://insights.amp-wp.org/admin/report/uuid/ampwp-2c37937f-1474-5871-856e-92cd1bf35954
Gutenberg Version
No response
OS(s) Affected
No response
Browser(s) Affected
No response
Device(s) Affected
No response
Acceptance Criteria
No response
Implementation Brief
No response
QA Testing Instructions
No response
Demo
No response
Changelog Entry
No response
The text was updated successfully, but these errors were encountered: