W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2012

Re: [whatwg] Implementation complexity with elements vs an attribute (responsive images)

From: Odin Hørthe Omdal <odinho@opera.com>
Date: Mon, 14 May 2012 00:30:20 +0000
To: Kornel Lesiński <kornel@geekhood.net>, whatwg@lists.whatwg.org
Message-ID: <cbb89b582f7b809a156f4be60caf1852@opera.com>
Kornel Lesiński said:
> Odin said:
>> Actually, for this to work, the user agent needs to know the size of the
>> standard image. So:
>>
>>   <img src="dog.jpg" width="960"
>>     srcset="dog@2.jpg 2x, dog-lo.jpg 500w">
>>
>> So if you've got the smartphone held in portrait, it's 250 css pixels
>> wide, and so 500 real pixels, it could opt to show dog-lo.jpg rather
>> than dog.jpg.
>
>But still displayed at 960 CSS pixels or course? That'd be fine (and the  
>UA could even download dog@2x when user zooms in).

Yes, that's a good thing to pinpoint. The picture will be in a 960 CSS
pixels box, but depending on the stylesheet - maybe

    img { max-width: 100%; height: auto }

It will ofc resize the backed picture down to fit that rule, when it
comes to the layout part. But yes, the picture will behave as if it is
960 px wide, only with lower dpi (resolution). Just the opposite of 2x
in fact.


All optional replacements of the src will have to be fitted in the same
box as the original src. That might actually require you to specify both
width and height upfront. Of course, people won't really do that, so I
guess we're bound to get differing behaviour... Hm.

What do people think about that? What happens here? You have no info on
the real size of the picture. I guess maybe the browser should never
load any srcset alternatives then? If you have no information at all
it's rather hard to make a judgement.

A photo gallery wants to show you a fullscreen picture, and give you:

   <img src=2048px.jpg srcset="4096px.jpg 2x">

In this example, us (humans :P) can easily see that one is 2048 px and the
other 4096 px. If I'm viewing this on my highres Nokia N9, a naïve
implementation could pick the 2x, because it knows that's nicely highres
just like its own screen.

But it would actually be wrong! It would never need anything else than
the 2048 px for normal viewing because it is anyway exceeding its real
pixels on the screen.

-- 
Odin Hørthe Omdal (odinho, Velmont), Core, Opera
Received on Monday, 14 May 2012 00:31:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:08 GMT