Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Responsive Images for Everybody

Responsive Images for Everybody

Slides from my talk at WordCamp Denver 2015, explaining the responsive image solutions that you can use today.

Joe McGill

June 14, 2015
Tweet

More Decks by Joe McGill

Other Decks in Technology

Transcript

  1. TL;DR We are visually oriented, but we need to be

    responsible with our use of images.
  2. New HTML Tools • The <picture> element • The srcset

    attribute • The sizes attribute • *Picturefill for compatibility
  3. srcset & w descriptors <img src="file.jpg" alt="a photo" srcset="file.jpg 300w,

    file-2x.jpg 600w,
 file-4x.jpg 1200w"> 38 38 TBD 25 9*/iOS9
  4. srcset + sizes = ! <img src="file.jpg" alt="a photo" srcset="file.jpg

    400w, file-2x.jpg 800w,
 file-3x.jpg 1200w"
 sizes="(max-width: 400px) 100vw, (max-width: 980px) 50vw, 400px" >
  5. <picture> <picture> <source media="(min-width: 1200px)"
 srcset="file-lg.jpg, file-lg-2x.jpg 2x"> <source media="(min-width:

    900px)" srcset="file-md.jpg, file-md-2x 2x.jpg"> <img srcset="file-sm.jpg, file-sm-2x.jpg 2x"
 alt="a nice photo"> </picture>
  6. Learn more • responsiveimages.org • Jason Grigsby: Responsive Images 101

    (blog.cloudfour.com) • Eric Portis: Responsive Images in Practice (A List Apart)