-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image natural dimensions strict to the precision of 4th decimal place #11505
Comments
Thanks for filing @zenofewords! #5356 is talking about a different audit. This audit's ratio is referring to the device pixel ratio NOT the aspect ratio of the image. It checks to make sure srcset/picture is being used to serve a large enough image with DPR taken into account. That being said, your images should actually pass in the latest version of Lighthouse (try Chrome Canary) which lowered this expectation to a max of 2x DPR (rather than the 3x shown in the screenshot). |
Thank you for the explanation and heads-up about the upcoming change, @patrickhulce! object-fit: cover; making the audit pass threw me off, still unclear why it would help in this case? |
|
Ah, OK I have an idea how it could be related. If the image's container dimensions are much larger such that using |
Unfortunately no URLs, still local, but you figured it out. The images are set to 100% width and auto height, looks like it fooled the audit. Alright, it's good to know I won't need to use |
Got back on my dev machine and tried setting both width and height to 400px. Also checked out canary (lighthouse 6.3.0), the audit still expects 3x, and |
The audit lists a higher DPR than it expects in 6.3.0, but internally should accept anything that's at least 2x. Do you have an example where 2x doesn't work?
That would be awesome :) |
Here's the repo and the netlify URL. I've added 2 sets of 2 images (red/blue and green/yellow). The only difference between the two is that that green/yellow also have Red/blue fail the audit, while the green/yellow pair passes, both on latest chrome and canary. Adding I'd expect |
Thanks so much for the detailed repro! I can see exactly what you're talking about in DevTools. Oddly though, the CLI sees the expected behavior and is not caught by this. We'll have to dig into why DevTools is ever flagging this red image since it should be big enough to pass our threshold 🤔
To correct my earlier statement though, apparently we do in fact explicitly ignore images with object-fit afterall 😆 (I'm guessing because if it's |
I'm going to let this issue track updating |
Thank you for the quick feedback! |
Hello, I noticed a "best practices" issue while testing some image srcsets. Here's a similar issue from 2018 (#5356) where the ratio check was loosened.
What is the current behavior?
At first, it looked like an image size issue, but using
object-fit: cover;
fixed it. So I checked the ratio and found that there are small differences between what's being displayed and the natural dimensions of the image.1st image displayed and expected vs displayed ratio is:
0.9473 (360x380, 1080x1140) vs 0.9478 (800x844)
2nd image displayed and expected vs displayed ratio is:
1.2631 (360x285, 1080x855) vs 1.2618 (800x634)
What is the expected behavior?
Unless I'm misunderstanding the "natural dimensions" audit, a check which is a little bit less strict.
Environment Information
The text was updated successfully, but these errors were encountered: