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

Re: [whatwg] responsive images

From: Glenn Maynard <glenn@zewt.org>
Date: Tue, 22 May 2012 10:02:10 -0500
Message-ID: <CABirCh9uJommnu8AuJjOFK3Lq56+oAC_bVrMptUS7d+fB936RA@mail.gmail.com>
To: Paul Court <paul@pmcnetworks.co.uk>
Cc: whatwg@lists.whatwg.org
(I wish people would stop starting new threads about the same topic.)

On Tue, May 22, 2012 at 5:53 AM, Paul Court <paul@pmcnetworks.co.uk> wrote:

> As a HTML author and programmer, I just cannot see myself implementing the
> current srcset proposal on sites. As a programmer, it has very much got
> what we would call a "bad code smell".
>
> <img src="face-600-200@1.jpeg" alt="" srcset="face-600-200@1.jpeg 600w
> 200h 1x, face-600-200@2.jpeg 600w 200h 2x, face-icon.png 200w 200h">
>

Actually, it's pretty clean; you've just made it ugly by sticking it all on
one line.

<img src="face-600-200@1.jpeg" alt=""
     srcset="face-600-200@1.jpeg 600w 200h 1x,
             face-600-200@2.jpeg 600w 200h 2x,
             face-icon.png       200w 200h">

It's no uglier than CSS syntaxes like background.

Not to mention, what happens when a 3x device is released?
> Do I have to change all my code again?
>

It'll use the best match, which is most likely the 2x version.

I'm also confused about what exactly 1x and 2x are. Is it 2x 72 or 2x 96?
>

It means two hardware pixels per CSS pixel, which is what you get on
iPhones, and also what you'll get if the user has zoomed in by 2x (eg.
ctrl-+ in most desktop browsers).  It's not related to DPI.

and isn't 600-200@2 just the same as 1200-400@1?
>

First, "600w 200h" does not mean a 600x200 image; it means an image
targetting 600x200 screens.  Some syntax changes have been discussed to
make this more clear.

Second, the "2x" means the the width and height of the image are 1/2 the
intrinsic dimensions of the image.  For example, if you have a logo which
is 400x150 on regular 1x displays, then a "2x" option would be an 800x300
image which is displayed as if you wrote <img src=url width=400
height=150>.  That means it takes the same amount of space in CSS
pixels--400x150--but you get the higher detail from the 2x density screen
(like iPhones), without changing the layout of the page.

-- 
Glenn Maynard
Received on Tuesday, 22 May 2012 15:04:54 GMT

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