[whatwg] add html-attribute for "responsive images"
David Goss
dvdgoss at gmail.com
Tue Feb 7 06:49:16 PST 2012
On 7 February 2012 13:42, Mathew Marquis <mat at matmarquis.com> wrote:
>
> On Tuesday, Feb 7, 2012, at 7:35 AM, David Goss wrote:
>>
>> On 7 February 2012 11:31:15 +0100, Anselm Hannemann wrote:
>>>
>>> This is a good solution except the fallback img element would be twice
>>> loaded in your case which is not good.
>>> There should be the img element containing the standard (normal) size and
>>> src elements to add diff. other resolutions. With that the browser won't
>>> load the resource twice.
>>
>> Would it? I think Matthew's example implies that a supporting browser
>> *wouldn't* load the src from the <img> unless none of the <source>s got a
>> media match. Right?
>>
>
> I’m not sure how it’s intended to work with <video> currently, but I believe
> the fallback is only loaded if <video> is unsupported—if none of the sources
> match, I believe nothing is displayed. I may be wrong, but that seems to be
> the most predictable behavior.
Ah, good point. <video> has its own src attrribute, which is where the
default source goes. Then it can be overridden by the last <source>
element with a media match, if any.
>>
>> I'm not really sure whether <source> should get an alt attribute - my
>> thinking is that if one alt attribute doesn't correctly describe all the
>> <source>s then perhaps they are different content. Matthew's example does
>> make sense, in that the extra alt attributes describe the way the image has
>> been cropped (although it's still the same image). But maybe it would be
>> better to only allow alt on the <img> to reinforce the idea that all the
>> <source>s should basically be the same image albeit
>> cropped/monochrome/whatever.
>>
>
> I’m with you, here. I’m hesitant to have any logic hinge on the fallback
> img, though, as it wouldn’t be strictly required—the fallback content could
> be, say, descriptive text instead (Granted I wouldn’t do it, but just trying
> to keep things as flexible as possible). I do think all sources should be
> described by a single alt tag, though, possibly on <picture> itself?
>
I guess I've moved away from similarities with <video>, in that I've
been thinking of the <img> as the default content, not the fallback
content. Going with your angle for a simple example with two sizes:
<picture alt="alternative text" src="default.jpg">
<source href="large.jpg" media="min-width:700px" />
<img alt="alternative text" src="default.jpg" />
</picture>
The duplication of the alt and default src attributes bothers me, but
on reflection perhaps it's better to have consistency with <video>.
More information about the whatwg
mailing list