34
Responsive Images in Drupal 8 By: Mario Hernandez August 27th, 2016

Responsive images in Drupal 8

Embed Size (px)

Citation preview

Page 1: Responsive images in Drupal 8

Responsive Images in Drupal 8

By: Mario Hernandez

August 27th, 2016

Page 2: Responsive images in Drupal 8

Mario HernandezFront-End Developer

@imariohernandez

Page 3: Responsive images in Drupal 8

Design/Theming● Usability Testing

● Responsive Design

● Drupal Theming

● Annotated Wireframes

@Mediacurrent

Development● Drupal Support

● Custom Module Development

● Large Scale Systems Integration

● Security & Performance Expertise

We help organizations build highly impactful, elegantly designed Drupal websites that achieve the strategic results you need.

Digital Strategy● Content Strategy

● Content Generation

● Result Metrics

● Marketing Automation Integration

Page 4: Responsive images in Drupal 8

● The problem

● Breakpoints

● Picture Element

● srcset & sizes attributes

● The Drupal Approach

● Demo

@Mediacurrent

Agenda

Page 5: Responsive images in Drupal 8

Blog Post

@Mediacurrent

mediacurrent.com/blog/responsive-images-d8

Page 7: Responsive images in Drupal 8

Ever since Ethan Marcotte started talking about responsive web design in 2010, developers and

designers have been scrambling to find ways to deal with the issue of responsive images

@Mediacurrent

Page 8: Responsive images in Drupal 8

What’s the problem with Media Queries

Page 9: Responsive images in Drupal 8

● Deliver only one final src● Be semantic● Be accessible● Be backwards-compatible● Accommodate art-direction● Work independently of any other language/technology

@Mediacurrent

What a solution looks like

Page 10: Responsive images in Drupal 8

@Mediacurrent

BreakpointsTHEME.breakpoints.yml

Page 12: Responsive images in Drupal 8

<picture>srcsetsizes

@Mediacurrent

Page 13: Responsive images in Drupal 8

<picture>

@Mediacurrent

Ideal for Art Direction

Page 15: Responsive images in Drupal 8

Source: http://caniuse.com

Browser support

Page 16: Responsive images in Drupal 8

http://scottjehl.github.io/picturefill/

Browser support

Picturefill

Page 17: Responsive images in Drupal 8

Identifying the gap

viewport dimensions no yes

image size relative to the viewport yes no

screen density no yes

source files’ dimensions yes no

Variable Known by author when writing the code?

Known by browser when it’s loading the page?

source: https://ericportis.com/posts/2014/srcset-sizes/

Page 18: Responsive images in Drupal 8

srcset & sizes

@Mediacurrent

attributes of the img tag

Ideal for resolution switching

Page 19: Responsive images in Drupal 8

srcset

@Mediacurrent

Ideal for resolution switching

Page 20: Responsive images in Drupal 8

sizes

@Mediacurrent

Ideal for resolution switching

Page 21: Responsive images in Drupal 8

srcset & sizes

@Mediacurrent

attributes of the img tag

Ideal for resolution switchingIdeal for Resolution Switching

Page 23: Responsive images in Drupal 8

Bridging the gap

viewport dimensions no yes

image size relative to the viewport yes yes via sizes

screen density no yes

source files’ dimensions yes yes via srcset

Variable Known by author when she’s writing the code?

Known by browser when it’s loading the page?

source: https://ericportis.com/posts/2014/srcset-sizes/

Page 24: Responsive images in Drupal 8

the picture element and the srcset and sizes attributes are being drafted into the HTML 5.1 specificationhttp://www.w3.org/TR/html51/

Page 25: Responsive images in Drupal 8

Quote“A high resolution image displayed on a low

resolution screen looks like low resolution image”~Mat Marquis

@Mediacurrent

Page 26: Responsive images in Drupal 8
Page 27: Responsive images in Drupal 8

How does all of this work in Drupal?

So glad you asked

@Mediacurrent

Page 28: Responsive images in Drupal 8
Page 29: Responsive images in Drupal 8

Responsive Images ModuleBackported to D7 as Picture Module

Breakpoints Module

Image Styles@Mediacurrent

Responsive Images and Breakpoints Modules are part of core in D8

Page 31: Responsive images in Drupal 8

Demo steps1. Create/Review Breakpoints

2. Enable Breakpoints and Responsive Images Modules

3. Create Image Styles

4. Create Responsive Image Styles

5. Configure Image Field with Responsive Image Styles

Page 32: Responsive images in Drupal 8
Page 33: Responsive images in Drupal 8

Resources● https://responsiveimages.org/

● Responsive Images for busy people

(https://builtvisible.com/responsive-images-for-busy-people-a-quick-primer/)

● http://blog.cloudfour.com/responsive-images-101-definitions/

● srcset & sizes: https://ericportis.com/posts/2014/srcset-sizes/

@Mediacurrent