3 ms·
In many cases you want to set one size and let the other calculate itself based on the aspect ratio of an image. And this is not know prior to loading and can't
by megous 8y ago
In many cases you want to set one size and let the other calculate itself based on the aspect ratio of an image. And this is not know prior to loading and can't be specified in any other way. So you get jumpy behavior during load on most responsive websites and slow connections. It's hard to fix in JS too.
- onion2k 8y agoYes, and that's exactly what Firefox's new scrolling anchoring tries to fix.
- wongarsu 8y agoIf only there was a way to know the aspect ratio of an image at the time of website authoring...
- ressetera 8y agoI personally dislike the complexity of having to use the server-side calculated dimensions. ``` object-fit: cover ``` comes to mind as a client-side solution I used in the past for this problem
- dredmorbius 8y agoThere are such things as dynamically sourced, or generated, images. On-the-fly-computed SVG data visualisations might be such a case. Generally, I'd agree that authoring time is some 9X% solution, though there remain edge cases.
- benj111 8y agoYou'd still want those at a fixed size though? I can't think of a good use case for auto generating arbitrarily large images, and as a user I wouldn't want to visit websites where the web designer thinks that's a good idea either.
- dredmorbius 8y agoUsually, yes, though posibly not in all cases. With SVG and CSS/JS, the size could be dynamic as the paage is being viewed, depending on user behaviour or other conditions What thos cases are is ... a good question, and my point is more thaat this can be done than to say why or that it's a good idea. Upshot again is that image size need not be deterministic at authoring time.
- phkahler 8y agoBut wouldn't that require people to know what they're putting on their web site?
- megous 8y agoDoesn't help if you try to do max-width: 100% in CSS. You'll get an image with a height you set in HTML and a smaller width.