W3C home > Mailing lists > Public > www-style@w3.org > January 2011

Re: [css3-images] image() function and file formats

From: Aryeh Gregor <Simetrical+w3c@gmail.com>
Date: Wed, 19 Jan 2011 11:59:35 +0200
Message-ID: <AANLkTik-W1FJCwRXFB5_5hVExG9y_Md6_RV4GTpU+GKf@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>, James Robinson <jamesr@google.com>
Cc: www-style list <www-style@w3.org>
On Tue, Jan 18, 2011 at 11:37 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> The CSS3 Images spec
> <http://dev.w3.org/csswg/css3-images/#image-notation> defines the
> image() function, which allows authors to specify multiple images,
> representing the first one that doesn't give an error (that is, if the
> first one 404s or similar, the browser will instead fetch the second
> one in the list, etc.).

To be pedantic, the request code should be irrelevant -- if a 404
response can be displayed as an image, it should be.

> Right now, the image() function has a form of light type-sniffing via
> the file extension, such that if the UA sees an image with an
> extension corresponding to a type of image the UA *knows* it doesn't
> support, it can skip trying to load the image altogether and just jump
> to the next image in the list.
> People have expressed concern that sniffing the image format via the
> file extension is unreliable and not a good practice.

I think it's unnecessary.  In practice, browsers tend to stay in
pretty close lockstep on what image formats to support and are not
eager to support new formats, so this is unlikely to actually happen
often enough to justify the new feature.  WebP, I guess?  Plus it's

> I don't have a strong opinion on the matter - I know that the file
> extension, in theory, doesn't say anything about the file, but also
> that in practice most files have the correct extension for their type.

Do they?  Do we have statistics on this?  For example, vBulletin (the
most popular closed-source forum software) serves all its images with
a .gif extension, last I checked, just so that they have a consistent
URL.  Most of them are actually PNG or JPEG.  (Maybe they changed this
in version 4, but the point stands.)

On Wed, Jan 19, 2011 at 12:27 AM, James Robinson <jamesr@google.com> wrote:
> I think if a UA really doesn't want to load a given image using whatever
> rule it feels inclined to, then it can go ahead to the next image in the
> list.  I don't think the extension language is necessary in the spec to
> allow a UA to skip .svg (for example) if it really wanted to.  I also agree
> that skipping URLs based on extension is probably not a great idea, but that
> seems like more of a quality of implementation issue.

I don't think UAs should skip if they're not sure they don't support
the earlier image.  Authors will surely put inferior fallbacks later
in the list, e.g., actual images followed by plain colors or gradients
as fallback, or vector images followed by bitmaps.  They should be
assured that the browser will load the best one if possible.
Received on Wednesday, 19 January 2011 10:00:27 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:07:54 UTC