Problem
If you use the preload option on a responsive image style which does use the sizes attribute in one of its breakpoints, then you get WSOD.
Here is the error message from the drupal log:
Error: Call to a member function value() on null in Drupal\blazy\BlazyFile::preload() (line 327 of DOCROOT/web/modules/contrib/blazy/src/BlazyFile.php)
Steps to reproduce
Use the preload option.
Choose a responsive image style.
Ensure in your chosen responsive image style that none of your breakpoints are using the option "select multiple image styles and use the sizes attribute".
Proposed resolution
Update line 327 to check that $item['sizes']->value() is not empty before trying to assign it.
Temporary workaround
Ensure at least one of your breakpoint uses "select multiple image styles and use the sizes attribute".
Marking this as "major" as this can break your site.
ps - Thank you very much for adding the preload option :)
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3264039-preload-sizes-10.patch | 103.74 KB | gausarts |
| #8 | 3264039-preload-sizes-8.patch | 95.19 KB | gausarts |
| #7 | 3264039-preload-sizes-7.patch | 76.96 KB | gausarts |
| #5 | 3264039-preload-sizes-5.patch | 76.65 KB | gausarts |
| #4 | 3264039-preload-sizes-4.patch | 29.14 KB | gausarts |
Comments
Comment #2
gausarts commentedThank you.
I'll get back to it soon.
Comment #3
gausarts commentedAdded sizes check.
Comment #4
gausarts commentedAdded supports for multiple hero-images like carousels as a bonus :)
Let's see if any issues.
Comment #5
gausarts commentedFixed for some @todos partially -- added settings grouping for sanity till all settings converted into BlazySettings at 3+:
https://git.drupalcode.org/project/blazy/-/blob/8.x-2.6/src/BlazySetting...
Merged them here for direct checks against these new preload stuffs.
Expecting misses due to fairly large changes.
Comment #7
gausarts commentedNarrowing issues down.
Comment #8
gausarts commentedFinalizing the session.
Comment #9
gausarts commentedFinalized the session.
Comment #11
gausarts commentedOther than the OP fix, a few additional fixes and bonus features were included:
settings.blazies` grouping for sanity and to avoid conflict with sub-modules till all settings converted into BlazySettings at 3+ as a pre-release partial @todo fix.OOT, just FYI, but still relevant to the included fixes:
Slick/ Splide have their own lazyload techniques:
nearby, progressive, ondemand, etc.But none supersedes Blazy lazy load technique efficiency. That is another valid reason they were designed to depend on Blazy.
Except the latest Splide in combo with Intersection Observer plugin. Or at most Slick's
ondemandwhich tends to be problematic for some design needs given like Colorbox integration.There is still a @todo to update them to respect Native better:
https://git.drupalcode.org/project/blazy/-/commit/f6c0282?page=2#bf64c0d...
As always, any misses may follow underground as guerilla fixes or bug reports.
Thanks.
Comment #12
xamountThank you! This is has solved my problem.