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

THE BIG PICTURE .

responsive images in action

PRESENTED BY MATTHIAS LAU

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

{ 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.",

}

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

!

A LOT!OPTIMIZED

THEY

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

!

FOR SMALL VIEWPORTSLARGE IMAGES

STILL...

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

RESPONSIVE DESIGNRESPONSIBLE

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

!

WANT!WE

WHAT

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

IMAGESOPTIMIZED

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

IMAGESOPTIMIZED

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

IMAGESOPTIMIZED

Page 12: The Big Picture: Responsive Images in Action #scd14

!

DIRECTIONART

Page 13: The Big Picture: Responsive Images in Action #scd14
Page 14: The Big Picture: Responsive Images in Action #scd14
Page 15: The Big Picture: Responsive Images in Action #scd14

!

IMAGESFAST

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

!

JAVASCRIPT

IT SHOULD

ALSO WORK WITHOUT

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

CACHING / CDN

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

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

!

CODESIMPLE

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

<object  data="data:image/svg+xml,%3Csvg%20viewBox='0%200%20300%20329'%20preserveAspectRatio='xMidYMid%20meet'%20xmlns='http://www.w3.org/2000/svg'%3E%3Ctitle%3EIguazu%20Waterfalls%3C/title%3E%3Cstyle%3Esvg%7Bbackground-­‐size:100%25%20auto;background-­‐repeat:no-­‐repeat;%7D@media%20screen%20and%20(max-­‐width:300px)%7Bsvg%7Bbackground-­‐image:url(http://localhost:8010/responsive_images/img/small.jpg);%7D%7D@media%20screen%20and%20(min-­‐width:301px)%7Bsvg%7Bbackground-­‐image:url(http://localhost:8010/responsive_images/img/medium.jpg);%7D%7D@media%20screen%20and%20(min-­‐width:601px)%7Bsvg%7Bbackground-­‐image:url(http://localhost:8010/responsive_images/img/big.jpg);%7D%7D@media%20screen%20and%20(min-­‐width:901px)%7Bsvg%7Bbackground-­‐image:url(http://localhost:8010/responsive_images/img/huge.jpg);%7D%7D%3C/style%3E%3C/svg%3E"  type="image/svg+xml">          <!-­‐-­‐  IE8  fallback  -­‐-­‐>          <!-­‐-­‐[if  lte  IE  8]>          <img  src="../img/medium.jpg"  alt="Iguazu  Waterfalls">          <![endif]-­‐-­‐>  </object>

!

ANYMORESIMPLE

NOT

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

TECHNIQUESRESPONSIVE IMAGE

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

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

SVG´sUSE

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

BACKGROUNDSCSS

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

BACKGROUNDSCSS

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

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

SIMPLE CODE

FAST

NOJS

CACHING / CDN

ART DIRECTION

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

IT IS A CSS IMAGE

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

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

ACCESSIBILITY

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

CARSCLOWN

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

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

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

<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>

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

<!-­‐-­‐  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 31: The Big Picture: Responsive Images in Action #scd14

SIMPLE CODE

FAST

NOJS

CACHING / CDN

ART DIRECTION

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

ADAPTIVE IMAGESRESS /

http://adaptive-images.com/

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

JS

Cookie

viewport width

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

.htaccess

image request Scaling Logic

best fitting image

Cookie

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

SIMPLE CODE

FAST

NOJS

CACHING / CDN

ART DIRECTION

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

RESIZINGSERVICES

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

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

RESIZING

SERVICES

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

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

<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 39: The Big Picture: Responsive Images in Action #scd14

SIMPLE CODE

FAST

NOJS

CACHING / CDN

ART DIRECTION

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

ELEMENTPICTURE

SRCSET+

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

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

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

<picture>          <source  media="(min-­‐width:  40em)"  src="medium.jpg">          <!-­‐-­‐  fallback  img  -­‐-­‐>          <img  src="medium.jpg"  alt="Iguazu">  </picture>

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

<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>

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

THE FANCY STUFFLET´S DO ALL

Page 45: The Big Picture: Responsive Images in Action #scd14

VIEWPORT SIZEIS NOT BLOCK SIZE

excursion:

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

<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>

Page 48: The Big Picture: Responsive Images in Action #scd14

<3

Page 49: The Big Picture: Responsive Images in Action #scd14

SIMPLE CODE

FAST

NOJS

CACHING / CDN

ART DIRECTION

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

NO BROWSER SUPPORT YET

Page 51: The Big Picture: Responsive Images in Action #scd14
Page 52: The Big Picture: Responsive Images in Action #scd14
Page 53: The Big Picture: Responsive Images in Action #scd14

PICTUREFILL

https://github.com/scottjehl/picturefill

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

SIMPLE CODE

FAST

NOJS

CACHING / CDN

ART DIRECTION

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

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 56: The Big Picture: Responsive Images in Action #scd14

WHAT?a summary

NOW

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

„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 #scd14

SOMETHINGUSE

please

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

WHERE POSSIBLE CSS IMAGES

OTHER PICTUREFILL

+ SVG´s

Page 60: The Big Picture: Responsive Images in Action #scd14
Page 61: The Big Picture: Responsive Images in Action #scd14
Page 62: The Big Picture: Responsive Images in Action #scd14
Page 63: The Big Picture: Responsive Images in Action #scd14
Page 64: The Big Picture: Responsive Images in Action #scd14

CONTEXT-BASEDIMAGES

forecast:

Page 65: The Big Picture: Responsive Images in Action #scd14

IMAGESE-COMMERCE

Page 66: The Big Picture: Responsive Images in Action #scd14
Page 67: The Big Picture: Responsive Images in Action #scd14
Page 68: The Big Picture: Responsive Images in Action #scd14
Page 69: The Big Picture: Responsive Images in Action #scd14
Page 70: The Big Picture: Responsive Images in Action #scd14
Page 71: The Big Picture: Responsive Images in Action #scd14

QUESTIONS?

http://twitter.com/matthiaslau

http://laumatthias.de/

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

Page 72: The Big Picture: Responsive Images in Action #scd14

PROCESSTHE

with grunt

Page 73: The Big Picture: Responsive Images in Action #scd14

grunt

original

Page 74: The Big Picture: Responsive Images in Action #scd14

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/'  }]


Recommended