

Using srcset, we’d mark up our image like so: We want to send large.jpg only to users with high-resolution screens. To do this, we’ll use the first tool that the new specification gives us for grouping and describing image sources: the srcset attribute. Let’s start simply, with a fixed-width image that we want to adapt to varying device-pixel-ratios. ( Image credit) The device-pixel-ratio Use Case Rearranging images across various resolutions is relatively easy, however, loading different images (and only them) depending on the user’s resolution is quite difficult. The new specification includes features for all of these cases. We’ll call this the type-switching use case. We might want to send a fancy new format such as WebP to browsers that can render it, and fall back to trusty old JPEGs in browsers that don’t.
Imageporter imagesize how to#
The latest specification of the element is the result of years of debate on how to make images adapt. Images have been the number one obstacle to implementing truly adaptable and performant responsive pages - pages that scale both up and down, efficiently tailoring themselves to both the constraints and the affordances of the browsing context at hand. Authors - wanting their images to look crisp in huge layouts and on high-resolution screens - began sending larger and larger sources to everyone the average size of an image file ballooned very smart people called responsive web design “ unworkably slow”. HTML authors began to really feel these limitations when high-resolution screens and responsive layouts hit the web like a one-two punch. And perhaps the great promise of the web, far from fulfilled as yet, is accessibility, regardless of difficulties, to information." "Everything I’ve said so far could be summarized as: make pages which are adaptable.… Designing adaptable pages is designing accessible pages. Everything about them has been stubbornly fixed: their size, format and crop, all set in stone by a single src. Images are some of the most important pieces of information on the web, but over the web’s 25-year history, they haven’t been very adaptable at all. There is [no reason to wait for responsive images we can actually have them very soon

Today’s article complements Tim Wright’s article and explains exactly how we can use the upcoming element and srcset, with simple fallbacks for legacy browsers. A few days ago, we published an article on Picturefill 2.0, a perfect polyfill for responsive images.
