responsive images

25
Responsive Images September 1, 2015 Paul Stonier | www.paulstonier.com | 607-358- 5199

Upload: paul-stonier

Post on 13-Apr-2017

288 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Responsive images

Responsive ImagesSeptember 1, 2015

Paul Stonier | www.paulstonier.com | 607-358-5199

Page 2: Responsive images

–Yoav Weiss

“Efficiently load properly dimensioned images that fit the page’s design”

Page 3: Responsive images

–Yoav Weiss

“Efficiently load properly dimensioned images that fit the page’s design”

Page 4: Responsive images

–Yoav Weiss

“Efficiently load properly dimensioned images that fit the page’s design”

Page 5: Responsive images

Mobile

• Bandwidth is expensive.

• Download speeds are slow.

Page 6: Responsive images

Images account for 56% of the average page’s total size.

http://www.webperformancetoday.com/2014/12/02/page-bloat-update-average-top-1000-web-page-1795-kb-size/

Page 7: Responsive images
Page 8: Responsive images
Page 9: Responsive images

Resolution-based selection

Developers generally want to provide the same image in multiple resolutions, so that high-res devices can get the optimum image for a given resolution, while low-resolution devices can avoid wasting time

and bandwidth downloading overly-large files.

https://usecases.responsiveimages.org/

Page 10: Responsive images

Responsive images can result in ~72% less image weight.

http://timkadlec.com/2013/06/why-we-need-responsive-images/

Page 11: Responsive images

Properly Dimensioned

Page 12: Responsive images

How do we fix it?

<img src="small.jpg" srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320w" sizes="(min-width: 1000px) 50vw, 100vw" alt=“kittens in a pumpkin">

If the screen size is 500px, small.jpg will load because it’s the largest size that fits within the viewport.

If the screen size is 700px, medium.jpg will load because it’s the largest size that fits within the viewport.

Page 13: Responsive images

How do we fix it?

<img src="small.jpg" srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320w" sizes="(min-width: 1000px) 50vw, 100vw" alt=“kittens in a pumpkin">

If the screen size is 1000px, small.jpg will load because it’s the largest size that fits within 50% of the viewport.

If the screen size is 2048px, large.jpg will load because it’s the largest size that fits within 50% of the viewport.

Page 14: Responsive images

How do we fix it?

<img src="small.jpg" srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320w" sizes="(min-width: 1000px) 50vw, 100vw" alt=“kittens in a pumpkin">

If the screen size is 1440px and 2X DPI, large.jpg will load because…

2x DPI results in (srcset width)/2. 1024w/2 = 512w

512w is the largest that will fit in the 50% of the viewport (720px)

Page 15: Responsive images

The x descriptor

<img src=“kittens-small.jpg” srcset=“kittens-hires.jpg 2x, kittens-medium.jpg 1.5x” sizes="100vw" alt=“kittens in a pumpkin">

Page 16: Responsive images

Why this works

http://ericportis.com/posts/2014/srcset-sizes/

Page 17: Responsive images

<picture>

• Art Direction

• Mime Type

Page 19: Responsive images

Art Direction

https://usecases.responsiveimages.org/#

Page 20: Responsive images

<picture>

<picture> <source media="(min-width: 40em)" srcset="big.jpg 1x, big-hd.jpg 2x"> <source srcset="small.jpg 1x, small-hd.jpg 2x"> <img src="fallback.jpg" alt=""></picture>

Page 21: Responsive images

<picture>

<picture> <source media="(min-width: 36em)" srcset="large.jpg 1024w,

medium.jpg 640w, small.jpg 320w"

sizes="33.3vw" /> <img src="fallback.jpg" alt="">

</picture>

Page 22: Responsive images

<picture>

<picture> <source type="image/svg" src="logo.svg" /> <source type="image/png" src="logo.png" /> <img src="logo.gif" alt="RadWolf, Inc." /></picture>

Page 23: Responsive images

WordPresshttps://make.wordpress.org/core/tag/respimg/

Drupal https://www.youtube.com/watch?v=TxNW0YNylLI

Grunt

https://github.com/nwtn/grunt-respimg

LazySizeshttps://github.com/aFarkas/lazysizes

https://responsiveimages.org/

THE RICG ON GITHUBhttp://gh.responsiveimages.org

IRC LOGShttp://ircbot.responsiveimages.org

DISCUSSION LIST ARCHIVEShttp://list.responsiveimages.org

Page 24: Responsive images

Questions?

Paul Stonier | www.paulstonier.com | 607-358-5199

Page 25: Responsive images

Thank you

Paul Stonier | www.paulstonier.com | 607-358-5199