[whatwg] responsive images srcalt proposal

pghj pghjvanblokland at gmail.com
Sat Jan 25 08:31:29 PST 2014


>
> We could minimize it dramatically if only a url-pattern and the available
> options are exposed instead of a long list of explicit urls:
>
> <img src="/path/to/foo-320w-240h-1x.jpg" width="320" height="240"
>     srcoptions="/path/to/foo-{width}-{height}-{dpr}.{format},    320w 480w 640w, 1x 1.33x 2x, webp jpg"/>
>
> Wouldn't this sort of thing be much easier to learn/read/write? Both
> humans and machines.
>
> I won't bother you with all the details here - I've tried to flesh out the
> idea in this gist: https://gist.github.com/rasmusfl0e/6727092
>


I think srcset refers to maximum device size, and your srcoptions to image
sizes, so I'm not sure about the equivalence mentioned in the linked
document.


 Wouldn't srcoptions produce many URL aliases? I'd say these are the same
image:

/path/to/foo-320w-240h-2x.jpg

/path/to/foo-640w-480h-1x.jpg

This would cause cache misses (in proxy servers), or introduce complexity
in the server for making redirects.

If srcoptions also intends for each image to be visually identical, I don't
see the point in including pixel densities anyway.

Furthermore, the naming convention will be incompatible with many existing
practices.


If compacting/DRYing of markup is an issue, I would propose the following
extension to srcalt:


 <img srcbase="/path/to/" srcalt="image200.jpg 200x300 5kB, image400.jpg
400x600 12kB" />

<img srcbase="/path/to/" srcalt="thumbnails/image.jpg 200x300 5kB, normal
/image.jpg 400x600 12kB" />

<img srcbase="/path/to/image.jpg" srcalt="?w=200 200x300 5kB, ?w=400
400x600 12kB" />

<img srcbase="/path/to/image.jpg" srcalt="?s=small 200x300 5kB, ?s=large
400x600 12kB" />


 where the URI reference in srcbase is resolved against the document base
URI, and the references in srcalt are in turn resolved against that. A
number of alternative naming schemes are shown. The last two offer the
greatest opportunity for compacting markup.


Josh.



More information about the whatwg mailing list