Problem/Motivation
During recent upgrade from drupal/core 9.5.11 => 10.1.6, we observed cases of either low-res images being loaded, or no image at all in some cases.
The js console contained the error:
Uncaught TypeError: Cannot read properties of null (reading 'replace')
at updateImage (resizer.js?s3j8ek:26:76)
Proposed resolution
This patch resolved the issue for us by checking whether image.getAttribute('data-multiplier')
has returned a null value, and if so then providing a default value for the multiplier
constant.
Note: this does not investigate what happens upstream. Other people looking at this might consider why the data-multiplier
attribute fails to get added in the first place.
Also, it's possible that there may be a better default value for the multiplier
constant than 1
(or perhaps a fallback method for calculating a multiplier without using same default in all cases).
A value of 1
seems to solve the issue in our case, though.
Remaining tasks
Review by community, if this patch is able to help anyone else.
User interface changes
n/a
API changes
n/a
Data model changes
n/a