Top Banner
Responsive Images in Drupal 8 By: Mario Hernandez November 17th, 2015
34

Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

May 21, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

Responsive Images in Drupal 8

By: Mario Hernandez

November 17th, 2015

Page 2: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

Mario HernandezFront-End Developer

@imariohernandez

Page 3: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

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...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

● The problem

● Breakpoints

● Picture Element

● srcset & sizes attributes

● The Drupal Approach

● Demo

@Mediacurrent

Agenda

Page 5: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

Blog Post

@Mediacurrent

mediacurrent.com/blog/responsive-images-d8

Page 7: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

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...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

What’s the problem with Media Queries

Page 9: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

● Deliver only one final src● Be semantic● Be accessible● Be backwards-compatible● Accommodate art-direction● Work independently of any other language/technology● Be agreeable to authors AND standards people AND

browser vendor people@Mediacurrent

What a solution looks like

Page 10: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

@Mediacurrent

BreakpointsTHEME.breakpoints.yml

Page 12: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

<picture>srcsetsizes

@Mediacurrent

Page 13: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

<picture>

@Mediacurrent

Ideal for Art Direction

Page 15: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

Source: http://caniuse.com

Browser support

Page 16: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

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

Browser support

Picturefill

Page 17: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

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...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

srcset & sizes

@Mediacurrent

attributes of the img tag

Ideal for resolution switching

Page 19: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

srcset

@Mediacurrent

Ideal for resolution switching

Page 20: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

sizes

@Mediacurrent

Ideal for resolution switching

Page 21: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

srcset & sizes

@Mediacurrent

attributes of the img tag

Ideal for resolution switchingIdeal for Resolution Switching

Page 23: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

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...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

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...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

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...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible
Page 27: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

How does all of this work in Drupal?

So glad you asked

@Mediacurrent

Page 28: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible
Page 29: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

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...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

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...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible
Page 33: Responsive Images in Drupal 8...responsive web design in 2010, developers and designers have been scrambling to find ways to deal with the issue of responsive images ... Be accessible

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