Skip to content
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

sizes attribute should directly set the intrinsic width of the image #3981

Open
tabatkins opened this issue Aug 30, 2018 · 1 comment
Open
Labels
needs implementer interest Moving the issue forward requires implementers to express interest normative change topic: img

Comments

@tabatkins
Copy link
Contributor

As currently defined, the sizes attribute on img/source doesn't have any direct effect on the image; instead, it expresses a desired intrinsic width. You then combine it with sources having a w descriptor, describing how wide the source is in image pixels. Dividing sizes by w thus gives you an effective density, which lets you choose between sources. Finally, when you actually download the image, if, the w descriptor was telling the truth (the image actually is that wide in image pixels), applying the effective density to it results in an intrinsic size equal to what you said in sizes.

This is roundabout, but it works. But it hinges on the w descriptor telling the truth; if it lies, and the image is actually a different width in image pixels, when you apply the effective density you'll get a different size than what sizes says. Thus, you can't tell what the intrinsic width will actually be until you download the image, even tho in normal situations you have all the information you need right there in the markup.

This causes some bad interactions with the proposed intrinsicsize attribute. In most cases it directly provides the intrinsic width/height, but we want to respect the sizes attribute, as it's useful and powerful; so instead, when used on a sizes/w-using source, it just provides the intrinsic ratio.

The problem, then, is that even tho we can virtually always count on sizes giving us an intrinsic width, and intrinsicsize giving a ratio, thus giving us an intrinsic height, technically we have to wait until the image is downloaded to tell what the actual intrinsic width will be, thus negating the benefit of intrinsicsize.

I think we can make this change compatibly: any image that is using w correctly will experience no change, and any image that is using it incorrectly would have already had confusing sizing behavior, such that this has a good chance of actually improving things.

@zcorpan
Copy link
Member

zcorpan commented Jun 28, 2023

intrinsicsize is now width and height attributes mapping to aspect-ratio: auto w / h.

@annevk annevk added normative change needs implementer interest Moving the issue forward requires implementers to express interest labels Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs implementer interest Moving the issue forward requires implementers to express interest normative change topic: img
Development

No branches or pull requests

3 participants