Re: [css-images] image() function with conditions

On Sun, Sep 1, 2013 at 10:42 PM, Dirk Schulze <dschulze@adobe.com> wrote:
> I know that there already have been proposals to add another argument beside STRING or URL on image() to give the browser a hint if it supports an image format before loading it. Such as:
>
>         background-image: image('image.webp' image/webp, 'image.png');
>
> A browser with support of WebP would load the first image, another that doesn't wouldn't even start to load the first image to see if it can be used.
> I like that idea, but think it can be extended. (Sorry if the following was proposed already, but I couldn't find a threat about it.)
>
> What about allowing conditions within image()? Something like the proposed srcset attribute on <img> element:
>
>         background-image: image('image-highDPI.png' 2x, 'image-lowDPI.png');
>
> Or in combination with the first proposal:
>
>         background-image: image(('image-highDPI.webp' image/webp 2x, 'image-highDPI.png' 2x, 'image-lowDPI.webp' image/webp, 'image-lowDPI.png');
>
> In my opinion, image() gets more interesting with capabilities like that.

Yes, more conditional stuff should be added to image() as we come up
with use-cases for it - it's the intended extension point for these
things.

Resolution negotiation in particular, though, is rather special - it's
not good to treat it as a strictly ordered list of alternatives.
image-set() is intended for that (and I think it's fine to add the
type annotations to image-set() as well, probably by defining a
grammar term that they both use).

~TJ

Received on Monday, 2 September 2013 07:41:37 UTC