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

The Big Picture: Responsive Images in Action #interactive_cgn

The Big Picture: Responsive Images in Action #interactive_cgn

Although responsive designs are already state-of-the-art in web development the whole trend still is in its infancy. When it comes to images, a lot of responsive websites just load the same big image on every viewport. Because of this, people judge responsive design as being detrimental to performance. New markup elements like are in development right now but what are the alternatives, what is the best to use right now, and how do they work? I will lead you through the different techniques and polyfills and show you their pros and cons. After this talk you should be able to choose the best fitting responsive image solution for your project.

Matthias Lau

May 24, 2014
Tweet

More Decks by Matthias Lau

Other Decks in Programming

Transcript

  1. { name: "Matthias Lau", link: "http://laumatthias.de", twitter: "@matthiaslau", hometown: {

    name: "Hamburg, Germany" }, bio: "E-Commerce Freak and Web-Allrounder, love coding, awesome internet concepts, Chrome, Web Frameworks, Evernote, the Apple Multi-Touch Trackpad, Bouldering, Wikipedia and Espresso.", }
  2. BACKGROUNDS CSS #iguazu  {        background-­‐image:  url(small.jpg);  

    }   @media  screen  and  (min-­‐width:  40em)  {        #iguazu  {              background-­‐image:  url(medium.jpg);        }   }
  3. <svg  xmlns='http://www.w3.org/2000/svg'>        <title>Iguazu  Waterfalls</title>      

     <style>              @media  screen  and  (min-­‐width:21em){                    svg{                          background-­‐image:url(http:// matthiaslau.github.io/responsive-­‐images/img/medium.jpg);                    }              }              @media  screen  and  (min-­‐width:40em){                    […]              }        </style>   </svg>
  4. <!-­‐-­‐  use  the  object  tag  for  maximal  browser  support  without

      security  drawbacks  -­‐-­‐>   <!-­‐-­‐  put  the  SVG  data  inline  to  prevent  a  second  HTTP   request  -­‐-­‐>   <object  data="data:image/svg+xml,%3Csvg%20viewBox=[…]"   type="image/svg+xml">          <!-­‐-­‐  IE8  fallback  -­‐-­‐>          <!-­‐-­‐[if  lte  IE  8]>          <img  src="medium.jpg"  alt="Iguazu  Waterfalls">          <![endif]-­‐-­‐>   </object>
  5. <img  alt="Iguazu"                

       src="medium.jpg"                    srcset="medium.jpg  1x,  medium-­‐2x.jpg  2x">
  6. <picture>          <source  media="(min-­‐width:  40em)"  src="medium.jpg">  

           <!-­‐-­‐  fallback  img  -­‐-­‐>          <img  src="medium.jpg"  alt="Iguazu">   </picture>
  7. <picture>        <source  media="(min-­‐width:  50em)"   srcset="large.jpg  1x,

     large-­‐2x.jpg  2x">          <source  media="(min-­‐width:  40em)"   srcset="medium.jpg  1x,  medium-­‐2x.jpg  2x">          <source  srcset="small.jpg,  small-­‐2x.jpg  2x">          <img  src="small.jpg"  alt="Iguazu">   </picture>
  8. <picture>      <source          sizes="(max-­‐width:  30em)

     100vw,  (max-­‐width:   50em)  50vw,  calc(33vw  -­‐  100px)"          srcset="xsmall.jpg  100w,  small.jpg  200w,   medium.jpg  400w,  large.jpg  800w,  huge.jpg  1600w,   monster.jpg  3200w">      <img  src="medium.jpg"  alt="Iguazu">   </picture>
  9. <3

  10. MORE THERE IS EVEN HiSRC Foresight.js Riloadr rwdImages Retina.js Responsive

    Enhance Doubletake Content Aware Resizing https://docs.google.com/spreadsheet/ccc?key=0Al0lI17fOl9DdDgxTFVoRzFpV3VCdHk2NTBmdVI2OXc#gid=0 Mobify..js
  11. „Don't click this if on a 3G network, it probably

    take forever, just check it out when you get home.“