4 ms·
A simpler solution might be <img src="image.jpg" sizes="640,800,1024"/> Then then the browser can choose the most appropriate size based on the screen siz
by ollysb 12y ago
A simpler solution might be
<img src="image.jpg" sizes="640,800,1024"/>
Then then the browser can choose the most appropriate size based on the screen size. The filenames would simply follow the convention, image-640.jpg, image-800.jpg etc. older browsers would simply use the original src.
- ollysb 12y agoAnother option would be to allow the source to be specified in css (stylesheets are loaded before images anyway). Then you could do <img id="cats" src="fallback_for_old_browser.png" /> @media (max-width: 600px) { #cats { src: url('http://cats.com/cats-600.png'); } }
- kaoD 12y agoNo please. CSS is meant for presentation, not content.
- swift 12y agoWe'll need a solution in CSS for properties like background-image and border-image. (Indeed, there have been multiple proposed solutions already.) It would be nice to use the same mechanism for both CSS and content images instead of introducing yet another case in the web platform where we have multiple slightly-incompatible mechanisms that do the same thing.
- Steuard 12y agoTo my eye, it's a little odd to read an article about multiple groups of experts who spent months or years hashing out a difficult problem, and then to see a comment like this one that proposes its own much simpler solution. Is your thought here that not one of the dozens of people involved considered this sort of syntax during those months or years or work? (That seems unlikely.) Or do you think their reasons for rejecting it were unsound? (You don't seem to have said why.) I'm just not understanding what you're aiming for here.
- ollysb 12y agoTheir proposed solution offers more flexibility in that you can use media queries to specify the upper/lower bounds and also specify the filenames. This feels over-engineered though, firstly because the above solution provides enough information to switch between images (we're not changing the layout here) and secondly because a filename convention is adequate for referencing them. The third reason that I dislike their solution is that it introduces presentation logic(media queries) into html.
- eurleif 12y agoArguably, <img> was already a form of presentation logic present in HTML. This just makes it more capable.
- tomjen3 12y agoCan we replace the WW3C with you? Then maybe they could, finally, get up to speed.