Aspect Switcher and Cropping Techniques
The evolution of web image formats
WebP
Better performance for both graphics and photography
Supports transparency and animation
AVIF
30-50% smaller than WebP at similar quality
Increasing browser support
Use WebP or AVIF with a WebP fallback
Otherwise you're wasting bandwidth and energy
Drupal provides options for image processing
Configure: Media → Image Toolkit
Check with your host for availability
Apply a series of effects to transform images
Order of effects is essential!
Different images for different devices
Older computer: 1024px viewport → smaller image
Modern mobile: 375px @ 3x density → larger image
It's not just about width!
Two approaches to responsive images
<img src="image.jpg"
srcset="image-small.jpg 400w,
image-medium.jpg 800w,
image-large.jpg 1200w"
sizes="(max-width: 600px) 100vw, 50vw">
Browser chooses based on viewport and pixel density
When you need different aspect ratios at different viewports
⚠️ Caution with user-uploaded images
Helping editors meet design requirements
We need better solutions!
Both require Crop API
Crop to any dimensions
Doesn't enforce ratio
Weird edge cases
Crop based on center point
✓ Works great for landscapes
Challenges with portraits
Even perfect focal point tagging can cut off heads or chins!
From the Image Effects module
Use different image styles based on aspect ratio
Landscape (>1:1)
Use Focal Point cropping
Portrait (≤1:1)
Place on canvas with background
No more cut-off heads!
More than just aspect switching
Let's see how this works in practice
Hard to beat on any platform
Empowers editors + maintains design integrity
Need help with image manipulation?
Connect on LinkedIn or Drupal Slack (@joshuami)
Questions?
This work is licensed under a Creative Commons Attribution 4.0 International License