-
Notifications
You must be signed in to change notification settings - Fork 14
Relationship to responsive image features #3
Comments
Yea I am trying to think in the case when there are different aspect-ratio wanted for responsive images, how can we achieve so by intrinsic-size attribute. |
|
That is, |
@tigt yup! You might have small changes because of rounding (3000×2000 → 188×125), dunno if those would ever matter? But per spec,
https://www.w3.org/TR/html/semantics-embedded-content.html#embedded-content-introduction If the aspect-ratio is changing in non-scaling-rounding related ways (e.g., 16:9 → 1:1), use multiple |
My bad. I didn't know the aspect-ratio would remain the same. However, I have a different opinion in terms of which solution is cleaner:
In addition, from an implementation's perspective, "intrinsic-size" attribute will be easier to parse ([number] x [number], and always in px unit). The logic is easier to implement and understand too. Adding an 'h' dimension sounds great and comprehensive, but it does add some complication, to both web dev and browser dev to interpret. Apologies in advance for my inexperience in web dev or any misunderstanding of this issue. |
Just saw your Intent to Implement on this, @loonybear. Thank you for pushing it forward! Let me check my understanding of the explainer. I’m worried that things might get a little weird and/or complicated re: intrinsic sizes and responsive images. Consider the following markup: <img
intrinsicsize="16x9"
srcset="small.jpg 640w, medium.jpg 960w, large.jpg 1024w, extra-large.jpg 1280w"
sizes="100vw"
/> Let's say the user agent picks I think the intent is that it would render at However, given the current kinda-vague language in the explainer, I worry...
I think the above image has:
So! Given the language of the explainer and my current understanding of the spec, I worry this markup in this context will render at This seems bad. Am I missing something? |
I agree with @eeeps here, and as a Web developer, I would prefer an |
intrinsicsize will work as an intrinsic ratio when it comes to responsive images. @tabatkins and I talked about the possibilities of modifying how responsive images determine intrinsic dimensions based on the "intrinsicsize" attribute. He might have more thoughts on how it will work with intrinsic density. |
Hi, I was looking at how responsive images calculates its source size , and I think the algorithm below would make "intrinsicsize" work well with responsive images: The “Intrinsicsize” attribute sets the image’s intrinsic aspect ratio, and the intrinsic width and height equivalent to descriptor ‘1x’.
|
For #2, intrinsic dimensions here are post-density correction, so there's no need to invoke density at all here. The value specified in Also, So, you can just collapse away the second bullet point entirely and just rely on the first and third. |
So basically: Sounds workable? I’ve got a question about how this might interact with Client Hints, but I’ll spin up another thread for that. A couple of markup-focused follow-ups:
|
Yes. I think that's the most reasonable interpretation here, as it preserves the full meaning of
I don't think so. Either we allow both
That's exactly what we do, yes. If |
Just to close the loop, for the two examples in the OP... <img srcset="300x200.jpg 300w, 600x400.jpg 600w, 800x533.jpg 800w" sizes="100vw" intrinsicsize="3x2" /> <picture>
<source
media="(max-width: 600px)"
srcset="cropped-square-sm.jpg 600w, cropped-square-lg.jpg 1200w"
sizes="100vw"
intrinsicsize="1x1"
/>
<img
srcset="full-16x9-sm.jpg 800w, full-16x9-med.jpg 1400w, full-16x9-lg.jpg 2000w"
sizes="100vw"
intrinsicsize="16x9"
/>
</picture> @ojanvafai, does any of this need to be captured in the explainer, or can it wait until there's a spec? |
Can't delete, sorry. Mesage above answered my question. |
Yes, they will be in spec. |
It's common to provide 2x images for high-DPI screens, as follows: <img src="foo.png" srcset="[email protected] 2x" width="100" height="100" intrinsicsize="??"> In this case, the intrinsic size of Update: The “How does this work with responsive images?” seems to cover this already, but it would be great to mention this common pattern explicitly in the README/FAQ. |
You're misusing terms. ^_^ The "intrinsic size" is what size it will naturally take up on the page, absent any CSS fiddling with it. In both cases, that size is 100px×100px (assuming that the 1x image is indeed 100×100 image pixels), because density correction is part of determining how something "naturally" lays out. (I don't think we have an agreed-upon term for "size in image pixels", so it's understandable that talking about this is a little awkward.) Note that, in your example, |
Yeah, I think we might need a dedicated section guiding people not to spam this on all their images, and to use width=""/height="" instead when possible. intrinsicsize="" only makes sense to use when you plan to use non-pixel widths/heights via CSS. |
Yes, but doesn’t this apply to the common pattern of (I’m honestly asking — if I misunderstood, I have a PR to revert 😅) |
@mathiasbynens i don't got such lines in my css i am wondering how you can think that it would be existing that often. Today People have some Fixed behavior for every screen Model. Most even resize images to fit for the targeted Screen so they work even without size Attributes |
@domenic What's the downside to Seems like we should try to depreciate |
(deleted previous post because it was wrong, sorry people following on in email!) Yeah, there's no benefit to sending |
Re:
Does your answer change if the CSS @ojanvafai @loonybear It would be highly valuable to add a clear mental model to the explainer, answering the question:
It'd help to get explicit guidance specifically for the following situations:
|
Yes. For the rest of your comment, yes, if HTML is the only source of sizing info, using If there's any CSS at all, |
Right now,
srcset
w
descriptors set the intrinsic width of the image.There was a lot of talk back in the day about adding an
h
descriptor, which would – in addition to allowing browsers to select sources for images whose layout size is constrained on height – set the intrinsic height of the resource.Does this proposal have any advantages over this (which was proposed but not yet spec'd or implemented):
?
I can see some disadvantages.
intrinsicsizes
would allow for different intrinsic sizes for the different resources in asrcset
or<picture>
. Where do theintrinsicsize
s go, and what should they be, on either of these images?In cases where
intrinsicsize
contradictsw
descriptors, what happens?The text was updated successfully, but these errors were encountered: