-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Ignore incorrect aspect ratio if the image is 1x1 pixel #6290
Comments
Thanks for filing @SebastianEberlein! I'm not sure I follow why your placeholder image needs to be so big if you set the actual size to be 1x1 anyhow. Maybe I'm misunderstanding but it seems like there's two possible paths with this neat trick you're using. Please correct me if I'm wrong :)
IIUC, it seems like you're using a transparent GIF the same size as the image it's placeholding, but then forcing it to not take up its natural placeholder size. With the current situation in the screenshot, there's no way of LH knowing that this seemingly regular sized image isn't being accidentally squished by some CSS rule which is one of the exact reasons the audit exists. |
@patrickhulce I'm pretty sure they use this lazyloading technique Sadly like @patrickhulce described we can't track down that your case is used for lazyloading. There are other ways to lazyload and keep your space filled in like flexembed techniques so your audit will pass 😛 |
Ooooooooh, wait I misread the screenshot as flipped 🤦♂️ 🤣 So so sorry @SebastianEberlein that makes perfect sense! You're already doing what I've described in bullet 1. Yeah we should ignore 1x1 source pixel images. |
For any potential contributors, these few lines are where we'd want to throw in a filter for the width/height being at least a few pixels (5px min maybe?) lighthouse/lighthouse-core/audits/image-aspect-ratio.js Lines 74 to 83 in 72a0932
|
Hi @patrickhulce , I'll try to fix this bug as my first contribution to lighthouse. Thank for the above code |
Good thing issue seems fixed :) |
Feature request summary
Ignore incorrect aspect ratio if the image is 1x1 pixel.
What is the motivation or use case for changing this?
Lazyloading images. The image container has an intrinsic ratio to avoid layout shifting. The placeholder image is a 1x1 pixel transparent base64 gif as suggested here.
Lighthouse 3.2.0 displays the warning "Displays images with incorrect aspect ratio":
This is technically correct, but should be ignored. A 1x1 pixel image will almost never match the natural aspect ratio. And it is unlikely that a 1x1 pixel image is used for anything other than a placeholder.
How is this beneficial to Lighthouse?
Seeing this warning, developers might look for a different solution, maybe a larger placeholder image with the correct aspect ratio. But this could increase the overall page size and thus degrade performance.
The text was updated successfully, but these errors were encountered: