Transcript
Page 1: The Big Picture: Responsive Images in Action #devcon13

THE BIG PICTURE .

responsive images in action

PRESENTED BY MATTHIAS LAU

Page 2: The Big Picture: Responsive Images in Action #devcon13

{ 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.", work: { employer: { name: "Jimdo"

}, },

}

Page 3: The Big Picture: Responsive Images in Action #devcon13
Page 4: The Big Picture: Responsive Images in Action #devcon13
Page 5: The Big Picture: Responsive Images in Action #devcon13

!

A LOT!OPTIMIZED

THEY

Page 6: The Big Picture: Responsive Images in Action #devcon13

!

FOR SMALL VIEWPORTSLARGE IMAGES

STILL...

Page 7: The Big Picture: Responsive Images in Action #devcon13

!

WANT!WE

WHAT

Page 8: The Big Picture: Responsive Images in Action #devcon13

IMAGESOPTIMIZED

Page 9: The Big Picture: Responsive Images in Action #devcon13

IMAGESOPTIMIZED

Page 10: The Big Picture: Responsive Images in Action #devcon13

IMAGESOPTIMIZED

Page 11: The Big Picture: Responsive Images in Action #devcon13

!

DIRECTIONART

Page 12: The Big Picture: Responsive Images in Action #devcon13
Page 13: The Big Picture: Responsive Images in Action #devcon13
Page 14: The Big Picture: Responsive Images in Action #devcon13

!

IMAGESFAST

Page 15: The Big Picture: Responsive Images in Action #devcon13

!

JAVASCRIPT

IT SHOULD

ALSO WORK WITHOUT

Page 16: The Big Picture: Responsive Images in Action #devcon13

CACHING / CDN

Page 17: The Big Picture: Responsive Images in Action #devcon13

<img  src="/img/funny-­‐cat.jpg">

!

CODESIMPLE

Page 18: The Big Picture: Responsive Images in Action #devcon13

TECHNIQUESRESPONSIVE IMAGE

http://matthiaslau.github.io/responsive-images/

Page 19: The Big Picture: Responsive Images in Action #devcon13

SVG´sUSE

Page 20: The Big Picture: Responsive Images in Action #devcon13

BACKGROUNDSCSS

Page 21: The Big Picture: Responsive Images in Action #devcon13

BACKGROUNDSCSS

#iguazu  {        background-­‐image:  url(small.jpg);  }  @media  screen  and  (min-­‐width:  601px)  {        #iguazu  {              background-­‐image:  url(medium.jpg);        }  }

Page 22: The Big Picture: Responsive Images in Action #devcon13

SIMPLE CODE

FAST

NOJS

CACHING / CDN

ART DIRECTION

Page 23: The Big Picture: Responsive Images in Action #devcon13

IT IS A CSS IMAGE

Page 24: The Big Picture: Responsive Images in Action #devcon13

<div  id="iguazu"  role="img"  aria-­‐label="Iguazu"></div>

ACCESSIBILITY

Page 25: The Big Picture: Responsive Images in Action #devcon13

CARSCLOWN

Page 26: The Big Picture: Responsive Images in Action #devcon13

<img  src="iguazu.svg"  alt="Iguazu  Waterfalls">

Page 27: The Big Picture: Responsive Images in Action #devcon13

<svg  xmlns='http://www.w3.org/2000/svg'>        <title>Iguazu  Waterfalls</title>        <style>              @media  screen  and  (max-­‐width:300px){                    svg{                          background-­‐image:url(http://localhost:8010/responsive_images/img/small.jpg);                    }              }              @media  screen  and  (min-­‐width:301px){                    […]              }        </style>  </svg>

Page 28: The Big Picture: Responsive Images in Action #devcon13

<!-­‐-­‐  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>

Page 29: The Big Picture: Responsive Images in Action #devcon13

SIMPLE CODE

FAST

NOJS

CACHING / CDN

ART DIRECTION

Page 30: The Big Picture: Responsive Images in Action #devcon13

ADAPTIVE IMAGESRESS /

http://adaptive-images.com/

Page 31: The Big Picture: Responsive Images in Action #devcon13

JS

Cookie

viewport width

Page 32: The Big Picture: Responsive Images in Action #devcon13

.htaccess

image request Scaling Logic

best fitting image

Cookie

Page 33: The Big Picture: Responsive Images in Action #devcon13

SIMPLE CODE

FAST

NOJS

CACHING / CDN

ART DIRECTION

Page 34: The Big Picture: Responsive Images in Action #devcon13

RESIZINGSERVICES

Page 35: The Big Picture: Responsive Images in Action #devcon13

http://src.sencha.io/320/200/http://[...]/huge-­‐hd.jpg

RESIZING

SERVICES

http://www.sencha.com/learn/how-to-use-src-sencha-io/

Page 36: The Big Picture: Responsive Images in Action #devcon13

<script  src='http://src.sencha.io/screen.js'></script>  !

<img          src='http://src.sencha.io/wiw/http://[...]/huge-­‐hd.jpg'          alt='Iguazu  Waterfalls'          />

RESIZING

SERVICES

Page 37: The Big Picture: Responsive Images in Action #devcon13

SIMPLE CODE

FAST

NOJS

CACHING / CDN

ART DIRECTION

Page 38: The Big Picture: Responsive Images in Action #devcon13

ELEMENTPICTURE

SRCSET+

Page 39: The Big Picture: Responsive Images in Action #devcon13

<picture>          <source  media="(min-­‐width:  601px)"  src="medium.jpg">          <source  src="small.jpg">          <!-­‐-­‐  fallback  img  -­‐-­‐>          <img  src="medium.jpg"  alt="Iguazu">          <!-­‐-­‐  alternate  text  -­‐-­‐>          <p>Iguazu</p>  </picture>

Page 40: The Big Picture: Responsive Images in Action #devcon13

<img  alt="Iguazu"                    src="small.jpg"                    srcset="medium.jpg  1x,  medium-­‐2x.jpg  2x">

Page 41: The Big Picture: Responsive Images in Action #devcon13

<picture>          <source  media="(min-­‐width:  601px)"  srcset="medium.jpg  1x,  medium-­‐2x.jpg  2x">          <source  src="small.jpg">          <!-­‐-­‐  fallback  img  -­‐-­‐>          <img  src="medium.jpg"  alt="Iguazu">          <!-­‐-­‐  alternate  text  -­‐-­‐>          <p>Iguazu</p>  </picture>

Page 42: The Big Picture: Responsive Images in Action #devcon13

<3

Page 43: The Big Picture: Responsive Images in Action #devcon13

SIMPLE CODE

FAST

NOJS

CACHING / CDN

ART DIRECTION

Page 44: The Big Picture: Responsive Images in Action #devcon13

NO BROWSER SUPPORT YET

Page 45: The Big Picture: Responsive Images in Action #devcon13
Page 46: The Big Picture: Responsive Images in Action #devcon13
Page 47: The Big Picture: Responsive Images in Action #devcon13

PICTUREFILL

https://github.com/Wilto/picturefill-proposalhttps://github.com/scottjehl/picturefill

Page 48: The Big Picture: Responsive Images in Action #devcon13
Page 49: The Big Picture: Responsive Images in Action #devcon13

SIMPLE CODE

FAST

NOJS

CACHING / CDN

ART DIRECTION

Page 50: The Big Picture: Responsive Images in Action #devcon13

MORETHERE IS EVEN

HiSRC

Foresight.js

Riloadr rwdImages

Retina.jsResponsive Enhance

DoubletakeContent Aware Resizing

https://docs.google.com/spreadsheet/ccc?key=0Al0lI17fOl9DdDgxTFVoRzFpV3VCdHk2NTBmdVI2OXc#gid=0

Mobify..js

Page 51: The Big Picture: Responsive Images in Action #devcon13

WHAT?a summary

NOW

Page 52: The Big Picture: Responsive Images in Action #devcon13

WHERE POSSIBLE CSS IMAGES

OTHER PICTUREFILL

+ SVG´s

Page 53: The Big Picture: Responsive Images in Action #devcon13

SOMETHINGUSE

please

Page 54: The Big Picture: Responsive Images in Action #devcon13

PROCESSTHE

with grunt

Page 55: The Big Picture: Responsive Images in Action #devcon13

grunt

original

Page 56: The Big Picture: Responsive Images in Action #devcon13

https://github.com/andismith/grunt-responsive-images

options:  {        sizes:  [              {                    name:  "s",                    width:  320,                    quality:  0.6              },              {                    name:  "s",                    suffix:  "x2",                    width:  640,                    quality:  0.6              },          […]                                                    ]  },

files:  [{        expand:  true,        cwd:  'img/',        src:  ['*.{jpg,gif,png}'],        dest:  'img/generated/'  }]

Page 57: The Big Picture: Responsive Images in Action #devcon13

„Don't click this if on a 3G network, it probably take

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

Page 58: The Big Picture: Responsive Images in Action #devcon13

CONTEXT-BASEDIMAGES

forecast:

Page 59: The Big Picture: Responsive Images in Action #devcon13

QUESTIONS?

http://twitter.com/matthiaslau

http://laumatthias.de/

https://www.xing.com/profile/Matthias_Lau


Top Related