SIZING UP RESPONSIVE IMAGES TALK MAKE A PLAN BEFORE YOU DRUPAL - - PowerPoint PPT Presentation

sizing up responsive images
SMART_READER_LITE
LIVE PREVIEW

SIZING UP RESPONSIVE IMAGES TALK MAKE A PLAN BEFORE YOU DRUPAL - - PowerPoint PPT Presentation

SIZING UP RESPONSIVE IMAGES TALK MAKE A PLAN BEFORE YOU DRUPAL JUNE 26, 2015 MARC DRUMMOND DATE SPEAKER Photo credit: Dave Emerson, Trouble, Flickr Creative Commons Marc Drummond Front-end Developer, Lullabot @MarcDrummond


slide-1
SLIDE 1

MARC DRUMMOND

TALK DATE SPEAKER

JUNE 26, 2015

SIZING UP RESPONSIVE IMAGES

MAKE A PLAN BEFORE YOU DRUPAL

Photo credit: Dave Emerson, “Trouble”, Flickr Creative Commons
slide-2
SLIDE 2 Photo credit: Dave Emerson, “Trouble”, Flickr Creative Commons

Marc Drummond

@MarcDrummond

mdrummond

IRC, drupal.org marcdrummond.com

Front-end Developer, Lullabot

slide-3
SLIDE 3

CERN, WE HAVE A PROBLEM

AND IT INVOLVES CATS

slide-4
SLIDE 4 Photo credit: Mr Thinktank, “SDC19276”, Flickr Creative Commons
slide-5
SLIDE 5 Photo credit: Doug Woods, “Midge Our Cute New Kitten Cat”, Flickr Creative Commons
slide-6
SLIDE 6 Photo credit: [paumelia], “so happy smiling cat”, Flickr Creative Commons
slide-7
SLIDE 7 Photo credit: Pete Teoh, “Aston Loves Andy”, Flickr Creative Commons
slide-8
SLIDE 8 Photo credit: Doug Woods, “Midge Our Cute New Kitten Cat”, Flickr Creative Commons
slide-9
SLIDE 9 Photo credit: Doug Woods, “Midge Our Cute New Kitten Cat”, Flickr Creative Commons
slide-10
SLIDE 10 Photo credit: Doug Woods, “Midge Our Cute New Kitten Cat”, Flickr Creative Commons
slide-11
SLIDE 11 Photo credit: Doug Woods, “Midge Our Cute New Kitten Cat”, Flickr Creative Commons
slide-12
SLIDE 12 Photo credit: Guyon Moree, “Angry Tiger”, Flickr Creative Commons
slide-13
SLIDE 13 Photo credit: Doug Woods, “Midge Our Cute New Kitten Cat”, Flickr Creative Commons
slide-14
SLIDE 14 Photo credit: [paumelia], “so happy smiling cat”, Flickr Creative Commons
slide-15
SLIDE 15 Photo credit: Mr Thinktank, “SDC19276”, Flickr Creative Commons
slide-16
SLIDE 16 Photo credit: Doug Woods, “Midge Our Cute New Kitten Cat”, Flickr Creative Commons
slide-17
SLIDE 17 Photo credit: Guyon Moree, “Angry Tiger”, Flickr Creative Commons
slide-18
SLIDE 18

SMALL SCREEN LARGE SCREEN SMALL PHOTO LARGE PHOTO

slide-19
SLIDE 19 Photo credit: Tina Lawson, “Heidi”, Flickr Creative Commons

What if we…

… provide different image files… … for different screen sizes?

Woh.

slide-20
SLIDE 20 Photo credit: Gonzolo G Useta, “La Ultima Vida”, Flickr Creative Commons

… browsers are fast Except…

slide-21
SLIDE 21 Photo credit: Tina Lawson, “Heidi”, Flickr Creative Commons

What if we…

… give browsers layout info… … in our HTML?

Woh.

slide-22
SLIDE 22
slide-23
SLIDE 23

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

PICTURE ELEMENT

slide-24
SLIDE 24

ART DIRECTION

DIFFERENT IMAGE CROPS PER MEDIA QUERY

slide-25
SLIDE 25

ART DIRECTION

DIFFERENT ASPECT RATIOS PER MEDIA QUERY

slide-26
SLIDE 26

IMAGE TYPES

.WEBP CAN FALLBACK TO .JPG

slide-27
SLIDE 27

<img ¡src="small.jpg" ¡ ¡ ¡ ¡ ¡ ¡srcset="large.jpg ¡1024w, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡medium.jpg ¡640w, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡small.jpg ¡320w" ¡ ¡ ¡ ¡ ¡ ¡sizes="(min-­‑width: ¡36em) ¡33.3vw, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡100vw" ¡ ¡ ¡ ¡ ¡ ¡alt="A ¡rad ¡wolf">

SIZES + SRCSET ATTRIBUTES

slide-28
SLIDE 28

PICTUREFILL

USE RESPONSIVE IMAGES IN OLDER BROWSERS

slide-29
SLIDE 29

DRUPAL 7

PICTURE AND BREAKPOINTS MODULES

slide-30
SLIDE 30

DRUPAL 8

RESPONSIVE IMAGE AND BREAKPOINT MODULES (IN CORE!)

slide-31
SLIDE 31

LET’S MAKE A PLAN.

slide-32
SLIDE 32

RESPONSIVE LAYOUTS ARE FLUID

IMAGE FILES ARE NOT

Photo credit: CelloPics, “Cat Only Loves Fresh Water”, Flickr Creative Commons
slide-33
SLIDE 33

TARGET / CONTEXT = RESULT

WIDTH %

slide-34
SLIDE 34

RASTER IMAGES

MEASURED IN PX, NOT %

slide-35
SLIDE 35

ANALYZE

HOW DOES THIS TYPE OF IMAGE FIT INTO THE SITE LAYOUT?

Photo credit: Jenny Lee Silver, “Photo A Day: June 2006”, Flickr Creative Commons
slide-36
SLIDE 36

Tiger sunbathing in a box

I am unable to envision anything quite as adorable as my cat Tiger lounging in the sun, cuddled in his precious little box. He has been a fan of this box since he was just a kitten, and we have preserved it ever since. When Tiger was just nine months

  • ld, we almost threw out this little half box. He mauled a couch

that day. The next day, we brought in the box from the recycling, and he has been a happy cat ever since. I have taken many photos over the years of Tiger cuddled in this box, but I love how the light looks in this particular picture. You can feel the warmth of the sun, Tiger purring, and envision him slowly closing his eyes and yawning. There are few moments more tender than those of a sunbathing cat.

Tiger cuddles in his box, basking in the sun.

Photo credits: Clare, “I Am Not Too Big For This Box” and “Does This Box Make Me Look Fat?”, Flickr Creative Commons
slide-37
SLIDE 37

Tiger sunbathing in a box

I am unable to envision anything quite as adorable as my cat Tiger lounging in the sun, cuddled in his precious little box. He has been a fan of this box since he was just a kitten, and we have preserved it ever since. When Tiger was just nine months old, we almost threw out this little half box. He mauled a couch that day. The next day, we brought in the box from the recycling, and he has been a happy cat ever

slide-38
SLIDE 38

this box, but I love how the light looks in this particular picture. You can feel the warmth of the sun, Tiger purring, and envision him slowly closing his eyes and yawning. There are few moments more tender than those of a sunbathing cat.

slide-39
SLIDE 39

Tiger sunbathing in a box

I am unable to envision anything quite as adorable as my cat Tiger lounging in the sun, cuddled in his precious little box. He has been a fan of this box since he was just a kitten, and we have preserved it ever since. When Tiger was just nine months

  • ld, we almost threw out this little half box. He mauled a couch

that day. The next day, we brought in the box from the recycling, and he has been a happy cat ever since. I have taken many photos over the years of Tiger cuddled in this box, but I love how the light looks in this particular picture. You can feel the warmth of the sun, Tiger purring, and envision him slowly closing his eyes and yawning. There are few moments more tender than those of a sunbathing cat.

Tiger cuddles in his box, basking in the sun.

HERO IMAGE

SIDE IMAGE

slide-40
SLIDE 40

<article ¡class="post"> ¡ ¡ ¡<figure ¡class="post__hero-­‑image"><img ¡src="images/ suncat.jpg" ¡alt="Golden ¡sunbeams ¡warm ¡a ¡cut ¡curled ¡up ¡in ¡ a ¡box." ¡/></figure> ¡ ¡ ¡<div ¡class="post__inner"> ¡ ¡ ¡ ¡ ¡<main ¡class="post__body" ¡role="main"> ¡ ¡ ¡ ¡ ¡ ¡ ¡<h1 ¡class="post__title">Tiger ¡sunbathing ¡in ¡a ¡box</ h1> ¡ ¡ ¡ ¡ ¡ ¡ ¡<p>I ¡am ¡unable ¡to ¡envision ¡… ¡sunbathing ¡cat.</p> ¡ ¡ ¡ ¡ ¡</main> ¡ ¡ ¡ ¡ ¡<aside ¡class="post__aside" ¡role="complementary"> ¡ ¡ ¡ ¡ ¡ ¡ ¡<figure ¡class="post__aside-­‑image"> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<img ¡src="images/suncat.jpg" ¡alt="Golden ¡sunbeams ¡ warm ¡a ¡cut ¡curled ¡up ¡in ¡a ¡box." ¡/> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<figcaption ¡class="post__aside-­‑image-­‑ caption">Tiger ¡cuddles ¡in ¡his ¡box, ¡basking ¡in ¡the ¡sun.</ figcaption> ¡ ¡ ¡ ¡ ¡ ¡ ¡</figure> ¡ ¡ ¡ ¡ ¡</aside> ¡ ¡ ¡</div> ¡ </article>

slide-41
SLIDE 41

HERO IMAGE

.post > .post__hero-image > img

slide-42
SLIDE 42

.post ¡{ ¡ ¡ ¡@media ¡(min-­‑width: ¡100em) ¡{ ¡ ¡ ¡ ¡ ¡left: ¡50%; ¡ ¡ ¡ ¡ ¡position: ¡relative; ¡ ¡ ¡ ¡ ¡transform: ¡translate(-­‑50%, ¡0); ¡ ¡ ¡ ¡ ¡width: ¡100rem; ¡ ¡ ¡} ¡ }

.POST RULES IMAGE RULES

img ¡{ ¡ ¡ ¡height: ¡auto; ¡ ¡ ¡width: ¡100%; ¡ }

slide-43
SLIDE 43

HERO IMAGE

Breakpoints .post .post__hero-image Final width Default 100% 100% 100% (min-width: 100em) 100rem 100% 100rem

slide-44
SLIDE 44

SIDE IMAGE

.post > .post__inner > .post__aside > .post__aside-image > img

slide-45
SLIDE 45

.post__aside ¡{ ¡ ¡ ¡padding: ¡5%; ¡ ¡ ¡width: ¡100%; ¡ ¡ ¡@media ¡(min-­‑width: ¡37.5em) ¡{ ¡ ¡ ¡ ¡ ¡float: ¡left; ¡ ¡ ¡ ¡ ¡padding: ¡2%; ¡ ¡ ¡ ¡ ¡width: ¡40%; ¡ ¡ ¡} ¡ ¡ ¡@media ¡(min-­‑width: ¡75em) ¡{ ¡ ¡ ¡ ¡ ¡padding: ¡1.5rem; ¡ ¡} ¡ }

.POST__ASIDE RULES

slide-46
SLIDE 46

SIDE IMAGE

Breakpoints .post .post__aside Final width Default 100% 100% - 5% x 2 90% (min-width: 37.5em) 100% 40% - 2% x 2 36% (min-width: 75em) 100% 40% - 1.5rem x 2 40% - 48px (min-width: 100em) 100rem 40% - 1.5rem x 2 640px - 48px

slide-47
SLIDE 47

BALLPARK FIGURES

DETERMINE INITIAL SOURCE FILE WIDTHS

Photo credit: Fuzzy Gerdes, “Parker Loooves the Cubs”, Flickr Creative Commons
slide-48
SLIDE 48

HERO IMAGE

Breakpoints Width Min px Max px Default 100% 320 1599 (min-width: 100em) 100rem 1600 1600

Min size: 320px Max size: 1600px

slide-49
SLIDE 49

RULE OF 25%

WIDTH X 1.25 HEIGHT X 1.25 PIXELS X 1.5625

56.25% MORE PIXELS

slide-50
SLIDE 50

HERO: RULE OF 25%

320 400 500 625 781.25 976.5625 1,220.703125 1,525.8789063 1,907.3486329

slide-51
SLIDE 51

SIDE IMAGE

Breakpoints Width Min px Max px Default 90% 288 540 (min-width: 37.5em) 36% 216 432 (min-width: 75em) 40% - 48px 432 592 (min-width: 100em) 640px - 48px 592 592

Min size: 288px Max size: 592px

slide-52
SLIDE 52

SIDE: RULE OF 25%

288 360 450 562.5 703.125

slide-53
SLIDE 53

SIDE: -25% FROM TOP

303.104 378.88 473.6 592

slide-54
SLIDE 54

TWICE AS NICE

SCREEN RESOLUTION DENSITIES

Photo credit: Mrs eNil, “Bed cuddles”, Flickr Creative Commons
slide-55
SLIDE 55

HERO: 2X SCREEN DENSITIES

320 400 500 625 781.25 976.5625 1,220.703125 1,525.8789063 1,907.3486329 640 800 1000 1250 1562.5 1953.125 2441.40625 3,051.7578125 3814.6972656

slide-56
SLIDE 56

SIDE: 2X SCREEN DENSITIES

303.104 378.88 473.6 592 606.208 757.76 947.2 1184

slide-57
SLIDE 57

TIDY UP

SENSIBLE SOURCE FILE WIDTHS

Photo credit: Sandra Forbes, “Clean Kitty”, Flickr Creative Commons
slide-58
SLIDE 58

HERO: TIDY NUMBERS

320 400 500 625 781.25 976.5625 1,220.703125 1,525.8789063 1,907.3486329 320 400 500 625 800 1000 1250 1600

slide-59
SLIDE 59

HERO: TIDY NUMBERS

320 400 500 625 800 1000 1250 1600

25% 25% 25% 28% 25% 25% 28%

slide-60
SLIDE 60

HERO: TIDY 2X

320 400 500 625 800 1000 1250 1600 640 800 1000 1250 1600 2000 2500 3200

slide-61
SLIDE 61

HERO: MORE TIDY 2X

320 400 500 640 800 1000 1280 1600 640 800 1000 1280 1600 2000 2560 3200

slide-62
SLIDE 62

HERO: MORE TIDY 2X

320 400 500 640 800 1000 1280 1600 640 800 1000 1280 1600 2000 2560 3200

slide-63
SLIDE 63

HERO: FINAL SOURCE WIDTHS

320 400 500 640 800 1000 1280 1600 2000 2560 3200

25% 25% 25% 28% 25% 25% 28% 25% 25.6% 25%

slide-64
SLIDE 64

HERO: FINAL SOURCE WIDTHS

320 400 500 640 800 1000 1280 1600 2000 2560 3200

11 source widths vs. 18 source widths

slide-65
SLIDE 65

SIDE: TIDY NUMBERS

303.104 378.88 473.6 592 300 375 470 600

slide-66
SLIDE 66

SIDE: TIDY NUMBERS

300 375 470 600

25% 27% 27.7%

slide-67
SLIDE 67

SIDE: TIDY 2X

300 375 470 600 600 750 940 1200

slide-68
SLIDE 68

SIDE: MORE TIDY 2X

300 375 470 600 600 750 940 1200

slide-69
SLIDE 69

SIDE: FINAL SOURCE WIDTHS

300 375 470 600 750 940 1200

25% 27% 25% 27.7% 25.33% 27.7%

slide-70
SLIDE 70

SIDE: FINAL SOURCE WIDTHS

300 375 470 600 750 940 1200 7 source widths vs. 8 source widths

slide-71
SLIDE 71

SIZES ATTRIBUTE

QUICK ACCESS LAYOUT INFO

Photo credit: London Looks, “Kittens!”, Flickr Creative Commons
slide-72
SLIDE 72

HERO: SIZES

<img ¡sizes="(min-­‑width: ¡100em) ¡100rem, ¡ 100vw"> ¡

Breakpoints Final width Sizes width Default 100% 100vw (min-width: 100em) 100rem 100rem

slide-73
SLIDE 73

SIDE: SIZES

<img ¡sizes="(min-­‑width: ¡100em) ¡ ¡37rem, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡(min-­‑width: ¡75em) ¡ ¡ ¡calc(40vw ¡-­‑ ¡3rem), ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡(min-­‑width: ¡37.5em) ¡36vw, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡90vw"> ¡

Breakpoints Final width Sizes width Default 90% 90vw (min-width: 37.5em) 36% 36vw (min-width: 75em) 40% - 48px calc(40vw - 3rem) (min-width: 100em) 640px - 48px 37rem

slide-74
SLIDE 74

SRCSET ATTRIBUTE

LIST IMAGE SOURCE FILES WITH WIDTHS

Photo credit: Mathias Erhart, “kittens”, Flickr Creative Commons
slide-75
SLIDE 75

HERO: SRCSET

320 400 500 640 800 1000 1280 1600 2000 2560 3200 <img ¡srcset=" ¡ ¡ ¡hero320.jpg ¡ ¡320w, ¡ ¡ ¡ ¡hero400.jpg ¡ ¡400w, ¡ ¡ ¡ ¡hero500.jpg ¡ ¡500w, ¡ ¡ ¡hero640.jpg ¡ ¡640w, ¡ ¡ ¡hero800.jpg ¡ ¡800w, ¡ ¡ ¡hero1000.jpg ¡1000w, ¡ ¡ ¡hero1280.jpg ¡1280w, ¡ ¡ ¡hero1600.jpg ¡1600w, ¡ ¡ ¡hero2000.jpg ¡2000w, ¡ ¡ ¡hero2560.jpg ¡2560w, ¡ ¡ ¡hero3200.jpg ¡3200w"> ¡

slide-76
SLIDE 76

SIDE: SRCSET

300 375 470 600 750 940 1200 <img ¡srcset=" ¡ ¡ ¡side300.jpg ¡ ¡300w, ¡ ¡ ¡ ¡side375.jpg ¡ ¡375w, ¡ ¡ ¡ ¡side470.jpg ¡ ¡470w, ¡ ¡ ¡side600.jpg ¡ ¡600w, ¡ ¡ ¡side750.jpg ¡ ¡750w, ¡ ¡ ¡side940.jpg ¡ ¡940w, ¡ ¡ ¡side1200.jpg ¡1200w"> ¡

slide-77
SLIDE 77

THIS SOUNDS LIKE A JOB FOR…

ROBOTS!

Photo credit: theresa21, “Daxie’s no match for the punching robots”, Flickr Creative Commons
slide-78
SLIDE 78

CSS RULES

MAKE IMAGES FLUID

Photo credit: Kevin Pelrine, “Leroy the Ruler”, Flickr Creative Commons
slide-79
SLIDE 79

IMAGE RULES img ¡{ ¡ ¡ ¡height: ¡auto; ¡ ¡ ¡width: ¡100%; ¡ }

slide-80
SLIDE 80

WIDTH: 100%

slide-81
SLIDE 81

MAX-WIDTH: 100% (MAYBE)

slide-82
SLIDE 82

HOLD UP. TIME TO DRUPAL.

slide-83
SLIDE 83

BREAK DANCING

BREAKPOINTS AND BREAKPOINT GROUPS

Photo credit: Trish Hamme, “Ta-Da !!!!”, Flickr Creative Commons
slide-84
SLIDE 84

Empty srcset is all we need

slide-85
SLIDE 85

Add breakpoint group: Sizes Select Empty srcset []

slide-86
SLIDE 86

Export to theme .info file? Optional.

slide-87
SLIDE 87

THEME.empty: ¡ ¡ ¡label: ¡Empty ¡ ¡ ¡mediaQuery: ¡'' ¡ ¡ ¡weight: ¡1

DRUPAL 8 BREAKPOINTS.YML

slide-88
SLIDE 88

SEND IN THE ROBOTS

IMAGE STYLES

Photo credit: Andy Miicone, “Miisa”, Flickr Creative Commons
slide-89
SLIDE 89

HERO: FILE WIDTHS

320 400 500 640 800 1000 1280 1600 2000 2560 3200

slide-90
SLIDE 90

SIDE: FILE WIDTHS

300 375 470 600 750 940 1200

slide-91
SLIDE 91

Image styles: Add style

slide-92
SLIDE 92

Name style: width_X rectangle_WxH square_WxH

slide-93
SLIDE 93
slide-94
SLIDE 94

Add width Allow upscaling

slide-95
SLIDE 95

LET’S MAP THIS OUT

PICTURE MAPPINGS AND FALLBACK STYLES

Photo credit: Little Dog Laughed, “Geography Cat”, Flickr Creative Commons
slide-96
SLIDE 96

Add mapping

slide-97
SLIDE 97

Select breakpoint group

slide-98
SLIDE 98

Mapping name Select sizes

slide-99
SLIDE 99

Add responsive image style Drupal 8!

slide-100
SLIDE 100

D8: Set fallback image style

slide-101
SLIDE 101

SIDE: SIZES

<img ¡sizes="(min-­‑width: ¡100em) ¡ ¡37em, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡(min-­‑width: ¡75em) ¡ ¡ ¡calc(40vw ¡-­‑ ¡3em), ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡(min-­‑width: ¡37.5em) ¡36vw, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡90vw"> ¡

slide-102
SLIDE 102

Enter sizes Select styles

slide-103
SLIDE 103

CHECK IT BEFORE YOU WRECK IT

IMAGE QUALITY MATTERS

Photo credit: Woodleyworks, “Lucky was inexorably drawn to the mirror”, Flickr Creative Commons
slide-104
SLIDE 104

Image quality

slide-105
SLIDE 105

Try lower: 60?

slide-106
SLIDE 106

STYLE SELECTIONS VIA UI

FIELD FORMATTERS AND YOU

Photo credit: George Pavlov, “I’m pretty kitty, right?”, Flickr Creative Commons
slide-107
SLIDE 107

Field display

slide-108
SLIDE 108

Change format to Picture

slide-109
SLIDE 109

Select mapping, fallback

slide-110
SLIDE 110

STYLE SELECTIONS VIA CODE

THEME PREPROCESSING FUNCTIONS AND MORE

Photo credit: Brian Dailey, “Cat + Code + Snow”, Flickr Creative Commons
slide-111
SLIDE 111

function ¡THEME_preprocess_node(&$variables) ¡{ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡if ¡($variables['type'] ¡== ¡'blog') ¡{ ¡ ¡ ¡ ¡ ¡$fallback_style ¡= ¡'width_400'; ¡ ¡ ¡ ¡ ¡ ¡ ¡if ¡($account ¡= ¡user_load($node-­‑>uid)) ¡{ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡if ¡(isset($account-­‑>picture-­‑>uri) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡&& ¡($mapping ¡= ¡picture_mapping_load('author_image')) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡&& ¡($breakpoints ¡= ¡ picture_get_mapping_breakpoints($mapping, ¡$fallback_style))) ¡{ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡$image_options ¡= ¡array( ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡'uri' ¡=> ¡$account-­‑>picture-­‑>uri, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡'alt' ¡=> ¡'', ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡'breakpoints' ¡=> ¡$breakpoints, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡'style_name' ¡=> ¡$fallback_style, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡); ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡$variables['user_picture'] ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡theme('picture', ¡$image_options); ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡} ¡ ¡ ¡ ¡ ¡ ¡ ¡} ¡ ¡ ¡ ¡} ¡ }

slide-112
SLIDE 112

¡ ¡$content['side_image_responsive'] ¡= ¡array( ¡ ¡ ¡ ¡ ¡'#type' ¡=> ¡'responsive_image', ¡ ¡ ¡ ¡ ¡'#uri' ¡=> ¡'public://side-­‑image.png', ¡ ¡ ¡ ¡ ¡'#attributes' ¡=> ¡array( ¡ ¡ ¡ ¡ ¡ ¡ ¡'alt' ¡=> ¡t('Hero ¡image'), ¡ ¡ ¡ ¡ ¡ ¡ ¡'title' ¡=> ¡t('Hero ¡image ¡title'), ¡ ¡ ¡ ¡ ¡), ¡ ¡ ¡ ¡ ¡'#responsive_image_style_id' ¡=> ¡'hero', ¡ ¡ ¡);

Simpler in D8!

slide-113
SLIDE 113

MAKE THE WEB BETTER Beautiful photos + Fast loading photos

slide-114
SLIDE 114 Photo credit: Pete Markham, “Domino the Cat, Week 2”, Flickr Creative Commons
slide-115
SLIDE 115 Photo credit: Dave Emerson, “Trouble”, Flickr Creative Commons

Marc Drummond

@MarcDrummond

mdrummond

IRC, drupal.org marcdrummond.com

Front-end Developer, Lullabot