Problem/Motivation
I noticed this problem after upgrading to Blazy 8.x-2.7.
The padding-bottom applied to the main div is sometimes wrong. It works after a page refresh.
If I re-visit the page in Incognito, the error repeats itself and is solvable by a page refresh.
What happens is the image ends up being distorted (height wise).

Before:
<div data-ratios="{"447":149.89,"455":60.44,"719":149.79}" style="padding-bottom: 149.79%;" data-ratio="149.79" class="media media--blazy media--bundle--recipe media--ratio media--ratio--fluid media--image is-b-loaded">......</div>
After page refresh
<div data-ratios="{"447":149.89,"455":60.44,"719":149.79}" style="padding-bottom: 60%;" data-ratio="149.79" class="media media--blazy media--bundle--recipe media--ratio media--ratio--fluid media--image is-b-loaded">...</div>
You can see the style="padding-bottom: 60%;"is set correctly after page refresh.
I thought this might be a problem with my cache or css/js aggregations, but even when turning off all caches and all aggregations, the error persists.
Setting a fixed aspect ratio also results in the same problem.
Let me know what other info I can provide that will help.
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | C-is-it-not-expected-Screenshot from 2022-03-01 21-10-21.png | 857.25 KB | gausarts |
| #22 | B-is-it-expected-Screenshot from 2022-03-01 21-16-18.png | 754.9 KB | gausarts |
| #22 | A-is-it-expected-Screenshot from 2022-03-01 21-09-07.png | 516.14 KB | gausarts |
| #15 | 3266748-fluid-15.patch | 49.91 KB | gausarts |
| #14 | 3266748-fluid-14.patch | 52.36 KB | gausarts |
Comments
Comment #2
xamountComment #3
gausarts commentedThank you.
Looks like 2 obvious regressions.
One here:
https://git.drupalcode.org/project/blazy/-/blob/8.x-2.x/js/blazy.compat....
Last one:
https://git.drupalcode.org/project/blazy/-/blob/8.x-2.x/js/blazy.compat....
You may want to minify it into its min.js file.
I am not handy now. Just reading the obvious misses, might be wrong :)
Does that fix the issue?
Comment #4
xamountHow should i go about doing this?
I have tried various settings within blazy. Nothing worked. I have no choice but to set the formatter to "Responsive image (lazy load)" until i can figure out a solution (essentially I turned off blazy).
Comment #5
gausarts commentedAttached to address the 2 mentioned regression issues.
The rest are non-committed local works aka bonuses, refinements, and attribute fixes.
FYI, Blazy 2.6+ has already decoupled lazy-load scripts, if any lazy basic issues you can always enable
No JavaScriptoption to behave like core lazy, instead. Only disabled when you need to support old browsers which can be toggled as needed. Aspect ratio, to fix reflow, might be no longer relevant when the image has dimensions set.Comment #7
gausarts commentedLet's make scrolling at tests behave more like human.
I can't think of any other reasons why it failed, certainly not with real browsers.
But likely the reason for the failing test was the end of body was too tall (filled in by Drupal json and script elements) causing the Intersection Obsever never feels it intersects images.
If still fails, something else breaks it.
Comment #9
gausarts commentedForgot we were on headless.
Let's see if still an issue.
Comment #11
gausarts commentedWe still need to refine the scrolling behavior to correctly reach the target element.
Comment #13
gausarts commentedFiguring out the problem one at a time.
Comment #14
gausarts commentedReverted tests to verify stupidity is somewhere else.
Comment #15
gausarts commentedFixed for CS.
Comment #17
gausarts commentedFeel free to re-open if still an issue.
FYI, in case the printed aspect-ratio numbers trick you:
window[onload|resize]. These basically provide a frame to minimize reflow issues before the image is actually loaded.Most likely they differ slightly given various window sizes. Yet, the
object-fit: coverbehaves almost similar tobackground-size: cover;. Meaning as long asblazy.cssis in place, and the correct aspect ratio applied, images are hardly distorted.Addition to "Aspect ratio, to fix reflow, might be no longer relevant when the image has dimensions set", as long as the
SRCimage is not as a placeholder. Once a placeholder, via olddata-SRC|SRCSET|LAZY, aspect ratio should be used.A note to myself for my future me since this type of failing tests repeat: isolate!
Thank you for contribution.
Comment #18
xamountI tried to apply the patch at #15 and also at #14 but both failed to apply. I ended up just using the 8.x-2.x-dev version but the problem still persists. I'm really stumped with this issue and I'm forced to turn off blazy. (I tried many things...many various aspect ratio, using/not using thumbnail place holder...nothing worked).
Can you also reproduce the problem?
Comment #19
gausarts commentedOk, I'd love to reproduce it :)
More details are required to narrow down:
blazy.cssloaded on the page? Disable aggregation for minute. CTRL + U and search for blazy.css.Let me know.
Comment #20
gausarts commentedPlease also save one of your trouble page as static HTML. Upload it somewhere, or zip it, and PM me the link via my Drupal contact form.
So it doesn't disrupt your production, and I can reproduce it. If you keep turning it off, I may not be able to see the problem.
Comment #21
xamountYes it is loading.
It works when I use it directly in the manage display of the content type image field. But I think it works there because the aspect ratio coincidently works in that scenario.
There are some console errors but these are not related to blazy. It's about ads on the site and some ad scripts not loading.
Thanks graciously for your help! I have PM'd you a zip.
Comment #22
gausarts commented>> Could you try using it without Views, at regular field UI? Any difference?
> It works when I use it directly in the manage display of the content type image field.
Ok, so it works fine at Field UI, but not Views rewrite UI.
I think this is part of the known issues:
https://www.drupal.org/project/blazy#blazy-known-issues
https://www.drupal.org/project/slick_views#slick-gotchas
"Having trouble with Views Rewrite results? Check this out. Shortly putting Blazy/ Slick formatters within Rewrite results box will break _only if using Aspect ratio fluid. Solution: use any alternative aspect ratio, except fluid. Added JS solutions at D8 2.x and D7 3.x branches."
Likely the provided solution kicks in late.
However I've seen your zip, and I see "no evil" :)
Please see attachments, and let me know your expectations. Watch out the file names, and A, B, C.
At all cases I see no distortion.
If A and B are expected, consider the provided solutions.
I also notice "zoom in" animation using
inview.jsfile which has errors. Try disabling this for a moment.Not sure if this zoom in effect shared the problem, but isolating one by one will help you.
Let me know if I should delete the uploaded screenshots. I removed anything else but pictures to show the problems.
Comment #23
xamount@gausarts Thanks very much for your help!
I finally figure it out and option A led me to solve the problem. So actually what was wrong was I should set choose similar cropped image styles for the breakpoints. After setting correct images styles for the relevant breakpoints, everything works.
Comment #24
gausarts commentedOk, thanks for the follow up. Glad we are on the same page :)
Setting it back to OP issue.