-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
img sizes="auto" skewing images using object-fit: contain #10079
Comments
As I understand it, the problem here is that the Authors should be able to set this intrinsic size with Once the Chrome bug is fixed, this should be work-around-able. However: would it be web compatible to have the |
Actually this does appear to be fixable with The codepen I linked above (https://codepen.io/eeeps/pen/bGZWZBq) is also working "properly" for me now. An hour ago the first dog face (in the <img>) was squished to 2:1 within its 1:1.5 box, I promise! It had large green letterbox bars; I should have taken a screenshot. |
Hmmm, I wonder if we should have @LeaVerou @tabatkins @fantasai any advice, as editors of css-images? cc @whatwg/css @progers @tcaptan-cr |
@eeeps with https://codepen.io/eeeps/pen/qBvmvwE I see stretched images in Chrome Canary 121 (I got an error with updating it seems), but resizing the window made the image switch to correct aspect ratio. I downloaded a new Chrome Canary, which was version 122 (still an error with updating), and now the image is not stretched. So maybe it was a bug that was fixed after 121? |
@progers @tcaptan-cr I see auto-sizes was unshipped in Chromium because of this issue (based on the referenced bugs), but the sites in question apparently don't have width/height attributes. We could make auto-sizes do nothing if the |
In my original example test case, it does look like the UA stylesheet was being applied and causing this issue, even though in my case the image markup does include
It makes me wonder if the UA stylesheet is being applied too broadly here. |
If you also remove |
The problem no longer occurs in Chrome 122.0.6261.57 |
Yes, because we switched the feature back to experimental mode due to several bug reports about this issue. |
Yes, the ones reported didn't have width or height attributes.
I can try it out. Do we need both |
Both are needed to give a correct aspect ratio. |
It is not clear to me that In Images Level 3, In Images Level 4, As all browsers currently do the same thing ( img:is([sizes="auto" i], [sizes^="auto," i]) {
contain: size !important;
contain-intrinsic-size: attr(width px, 300px) attr(height px, 150px);
} But I would like to hear from the CSS Images folks (@LeaVerou @tabatkins @fantasai) before we 100% commit to |
I think it's a mistake for |
Correction! I said,
But I was wrong, Firefox doesn't (and also doesn't use the actual natural aspect ratio, instead |
@eeeps can you file a new issue in w3c/csswg-drafts? |
I filed https://bugzilla.mozilla.org/show_bug.cgi?id=1886745 , thx! |
If w3c/csswg-drafts#10116 is fixed, it seems to me that auto-sizes can stay as currently specified. |
I agree and will re-land it in Chrome once it's fixed. |
Auto sizes was re-enabled in Chromium in https://issues.chromium.org/issues/40862170 and it looks like the image skewing issue is not longer present in my original test case. |
Thanks for confirming! |
What is the issue with the HTML Standard?
While testing the implementation for auto sizes in the latest Chrome betas (v121) I noticed that images using
object-fit: contain
were getting skewed. I've created a reduced test case to demonstrate the behavior I'm seeing.I noticed in #4654 (comment) that @aFarkas mentioned some known quirks with calculating height with object-fit, so perhaps this is expected behavior? Wondering if @zcorpan has any advice here.
The text was updated successfully, but these errors were encountered: