Edit (2026) using Claude: This issue now has a concrete implementation plan. See Proposed Resolution below for the full scope. The remaining tasks section links to all child issues. Source material for the plan comes from: https://gist.github.com/heddn/4c589071a0bcd13906c6cb6a7e9f2be6
Problem/Motivation
It's possible to configure responsive images in Drupal so as to optimize their loading time by using modern HTML5 image features:
<picture>, sizes, srcset, and modern image formats such as WebP and AVIF.
But:
- It's not easy to understand how to configure this, especially if you're unfamiliar with those HTML5 features.
- It's not quick to do in the Drupal admin UI, nor easy to maintain (avoiding mistakes, making changes afterwards).
The core problem: before you can configure a responsive image style, you must first create many non-responsive image styles — one or more for each breakpoint width. Mostly they're all configured the same way with just a different width. If you want to fix or change something about the image styling, you have to fix all of them manually. For N image types and 4 breakpoint widths, you're managing 4×N image styles. The maintenance burden means most sites simply don't do responsive images correctly.
From a site builder's perspective: for a given image use case, it should be possible to configure everything once at the responsive image level — not 85+ individual styles.
Proposed Resolution
Introduce Responsive Image Configuration (declarative): a new config entity that replaces the existing imperative Responsive Image Configuration (legacy) model. Instead of manually creating one ImageStyle per breakpoint/size and mapping each to a breakpoint, a site builder specifies intent once — base dimensions, breakpoints, pixel densities, and output formats — and the system generates all required variants automatically.
Key design decisions:
- Declarative model: 1 Responsive Image Configuration (declarative) replaces 85+ manually created ImageStyle entities for full responsive coverage.
- Effects chain: Site builder defines non-size effects (strip_exif, desaturate, sharpen, etc.) using the existing
ImageEffectplugin system. The system owns all sizing — it scales to the target breakpoint × DPR width, then applies the effects chain. Format conversion is a separate selector, not an effect. - Formats: Selected from a hard-coded list (
webp,avif,jpeg,png), extensible via aResponsiveImageFormatsEvent. WebP + original format fallback by default; AVIF added when toolkit support is sufficiently widespread. - Breakpoints: Sourced from the active theme's breakpoint definitions via
BreakpointManagerInterface. - Admin UI: Declarative and legacy configurations shown in separate sections; "Add new" only available for declarative configurations.
- Cache-safe URLs: Derivative directories use
{config_name}__{xxh3_hash}— config changes automatically rotate the URL namespace, no explicit cache flush required. - Upgrade path: Existing Responsive Image Configuration (legacy) entities are automatically migrated on
drush updatedbvia a dedicatedResponsiveImageConfigurationUpgraderservice. No manual steps required for site builders. - Backwards compatibility:
ImageStyleInterfaceand allimage.moduleformatter APIs are unchanged. Plain ImageStyles are not deprecated. - Prerequisite: #2986669: Split ImageStyle into the config entity and a separate event-based image processing service Split ImageStyle into config entity + processing service must land first.
Requirements
Functional Requirements
| # | Requirement | Area |
|---|---|---|
| FR1 | Site builder can create a Responsive Image Configuration (declarative) specifying base size, breakpoints, DPR range, and output formats | Configuration Management |
| FR2 | Site builder can edit an existing Responsive Image Configuration (declarative) | Configuration Management |
| FR3 | Site builder can list all Responsive Image Configurations (declarative and legacy) | Configuration Management |
| FR4 | Site builder can delete a Responsive Image Configuration (declarative) | Configuration Management |
| FR5 | Site builder can select breakpoints from those defined by the active theme | Configuration Management |
| FR6 | Site builder can select output formats (WebP, AVIF, fallback JPEG) per configuration | Configuration Management |
| FR7 | Site builder can select DPR variants (1x, 2x, 3x, 4x) per configuration | Configuration Management |
| FR8 | Site builder can preview the number of variants that will be generated before saving | Configuration Management |
| FR9 | The system generates a deterministic variant manifest ({size × format × DPR} tuples) from a configuration | Variant Generation |
| FR10 | The system generates image derivatives on first request (lazy generation) | Variant Generation |
| FR11 | The system caches generated derivatives for subsequent requests | Variant Generation |
| FR12 | The system produces identical derivative URLs for identical configuration + source image combinations | Variant Generation |
| FR13 | The system generates WebP derivatives when the image toolkit supports WebP | Format Processing |
| FR14 | The system generates AVIF derivatives when the image toolkit supports AVIF | Format Processing |
| FR15 | The system falls back to the configured fallback format when a requested format is unsupported by the toolkit | Format Processing |
| FR16 | The system detects available toolkit format capabilities at configuration validation time | Format Processing |
| FR17 | The system renders a <picture> element with <source> elements per breakpoint × format when a Responsive Image Configuration (declarative) is applied to a field formatter |
Responsive Image Rendering |
| FR18 | The system generates correct srcset attributes with variant URLs for each configured DPR |
Responsive Image Rendering |
| FR19 | The system renders a fallback <img> element within the <picture> element |
Responsive Image Rendering |
| FR20 | The system passes the alt attribute from the image field through to the rendered <img> element |
Responsive Image Rendering |
| FR21 | Site builder can attach a Responsive Image Configuration (declarative) to a responsive image formatter | Responsive Image Rendering |
| FR22 | The system automatically migrates Responsive Image Configuration (legacy) entities to equivalent Responsive Image Configuration (declarative) entities on database update | Migration & Upgrade |
| FR23 | The migrated configuration produces <picture> output equivalent to its legacy predecessor |
Migration & Upgrade |
| FR24 | The system displays an admin notice after migration with a succinct description of what was automatically updated | Migration & Upgrade |
| FR25 | The admin UI displays a warning when a configuration references formats not supported by the current server's image toolkit | Administration & Warnings |
| FR26 | Core ships at least one default Responsive Image Configuration (declarative) available on a fresh install | Administration & Warnings |
| FR27 | Site builder can switch a field formatter between image (ImageStyle) and responsive image (Responsive Image Configuration) display modes |
Administration & Warnings |
| FR28 | Responsive Image Configuration (declarative) entities are exportable and importable via Drupal's config management system | Config System Integration |
| FR29 | Contrib modules can ship default Responsive Image Configuration (declarative) entities via config/install/ YAML files |
Config System Integration |
| FR30 | Contrib modules and themes can reference a Responsive Image Configuration (declarative) by machine name ID | Config System Integration |
Non-Functional Requirements
| # | Requirement | Area |
|---|---|---|
| NFR1 | Variant cache hit rate must be >95% for repeat requests on a warm cache | Performance |
| NFR2 | First-request variant generation is best-effort and toolkit-dependent; no minimum latency target. Sites requiring guaranteed first-request performance should use contrib async pre-generation. | Performance |
| NFR3 | The admin UI must be sufficiently responsive to allow a site builder to complete configuration within 5 minutes | Performance |
| NFR4 | Access to create, edit, and delete Responsive Image Configuration (declarative) entities is controlled by Drupal's permission system | Security |
| NFR5 | Derivative URL signing (itok token) is inherited unchanged from the existing image derivative system; no new security mechanisms required | Security |
| NFR6 | The system must function correctly with up to 255 variants per configuration without errors or degraded output | Scalability |
| NFR7 | Multiple Responsive Image Configurations (declarative) may be active simultaneously on a single site without interference | Scalability |
| NFR8 | The Responsive Image Configuration admin UI must meet WCAG 2.1 AA — the Drupal core admin UI standard | Accessibility |
| NFR9 | ImageStyleInterface and all image.module formatter APIs remain unchanged for the full Drupal 12.x lifecycle |
Backwards Compatibility |
| NFR10 | Existing image derivatives generated by ImageStyles continue to be served without regeneration after upgrade | Backwards Compatibility |
| NFR11 | The admin UI must pass Drupal core UX team approval before admin UI stories can be committed to core | Governance |
Remaining Tasks
| # | Task | Phase | Related issues |
|---|---|---|---|
| 0 | Split ImageStyle into the config entity and a separate event-based image processing service | Prerequisite | #2986669: Split ImageStyle into the config entity and a separate event-based image processing service |
| 1.1 | Implement ResponsiveImageToolkitChecker service — detect WebP/AVIF/format support from active toolkit at config validation and render time |
Phase 1: Latent Backend | |
| 1.2 | Move Canvas ParametrizedImageStyle to core as ResponsiveImageDeclarativeStyle config entity — schema, config export/import, permissions, contrib install config support |
Phase 1: Latent Backend | #3588267: Move Drupal Canvas ParametrizedImageStyle ecosystem to core and provide CKEditor integration |
| 1.3 | Implement ResponsiveImageVariantGenerator — deterministic variant manifest ({size × format × DPR} tuples) with xxh3-hashed URL scheme |
Phase 1: Latent Backend | |
| 1.4 | Derivative generation — lazy first-request generation, caching, WebP + format fallback chain | Phase 1: Latent Backend | #3213491: Add fallback format support to responsive images, #3406238: All new image styles should convert to WebP by default, #3422320: Provide global setting for conversion of all images in specific format |
| 1.5 | AVIF format support with graceful fallback | Phase 1: Latent Backend | #3516434: Consider falling back to webp from AVIF based on filesize, #3213491: Add fallback format support to responsive images |
| 1.6 | Implement ResponsiveImageRenderer — <picture> element, srcset, fallback <img>, alt passthrough (dormant until Phase 2) |
Phase 1: Latent Backend | #3213491: Add fallback format support to responsive images |
| 1.7 | Ship default Responsive Image Configuration (declarative) via config/optional/ (WebP + original format fallback, activates when theme breakpoints are available) |
Phase 1: Latent Backend | |
| 2.1 | Admin UI form — create/edit/list/delete Responsive Image Configuration (declarative) with breakpoint picker, format/DPR selectors, variant count preview, toolkit mismatch warning (requires UX team approval) | Phase 2: Coordinated Push | |
| 2.2 | Update ResponsiveImageFormatter to accept Responsive Image Configuration (declarative) and activate ResponsiveImageRenderer |
Phase 2: Coordinated Push | |
| 2.3 | Wire post-update hook to ResponsiveImageConfigurationUpgrader — auto-migrate all Responsive Image Configuration (legacy) entities on drush updatedb; admin notice describing what changed |
Phase 2: Coordinated Push |
User Interface Changes
New admin UI for Responsive Image Configuration (declarative) (Phase 2, requires UX approval):
- Create/edit form: breakpoint picker (sourced from active theme), format checkboxes (WebP, AVIF, fallback), DPR selector (1x–4x), variant count preview
- Admin listing page: Responsive Image Configuration (legacy) and (declarative) in the same list, distinguished by type indicator; legacy
configurations show upgrade prompt - Cross-environment warning: admin UI displays a warning when a configuration references formats not supported by the current server's image toolkit
- No changes to the
image.moduleformatter UI
API Changes
- New services:
responsive_image.toolkit_checker,responsive_image.variant_generator,
responsive_image.renderer,responsive_image.configuration_upgrader - Derivative URL scheme for new configurations:
{config_name}__{xxh3(breakpoints|dpr|formats|effects)}— full 16-char hex hash - Existing APIs unchanged:
ImageStyleInterface,hook_image_style_*,image.moduleformatter paths — no deprecations
Data Model Changes
- New config entity schema:
responsive_image.declarative_style.*— stores machine name, breakpoint IDs, DPR variants, format selection, fallback format, effects array - Default configuration:
responsive_image.declarative_style.defaultships inconfig/optional/ - Existing
responsive_image.styles.*entities unchanged and not deprecated
Release Notes Snippet
Drupal now includes Responsive Image Configuration (declarative): configure responsive images once — base size, breakpoints, pixel densities, and formats — and the system generates all required variants automatically. A single configuration replaces the 85+ manually-created ImageStyle entities previously required for full responsive coverage. Existing Responsive Image Style configurations are automatically migrated on database update.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | responsive-image-styles.png | 228.89 KB | seanb |
Comments
Comment #2
seanbThanks for this issue! As the maintainer of the Easy Responsive Images module, I have struggled with this before. When working with responsive images in core, the following issues were the most important reasons we created the Easy Responsive Images module:
You need to create a lot of image styles / Configuring responsive image styles is quite complex
Since the amount of use cases is huge, it is very hard to come up with a solution that is easy to use, yet supports everything. It would already greatly help if all the configuration for responsive images can be done in 1 place, letting it generate the image styles it needs in the background. As long as it cleans up/updates generated styles when you change things (maybe even lock generated styles and hide them), they won't complicate the interface for "regular" image styles.
The responsive image styles could then be an interface similar to regular image styles, just with breakpoints.

The picture element selects images based on the browser width, not the width of the image container
This would definitely need a JavaScript-based solution at the moment. There is awesome work being done to make the sizes attribute for images support the "auto" value. That would be amazing, and it could be worth it to wait for this. Or we could just accept the limitations for now and already move from picture elements to image elements with sizes attribute.
Output WebP for image by default
This is currently done using the WebP module or ImageAPI Optimize WebP. I agree, it would be nice if core would just do this. All major browsers support it, so not sure if there is a good reason not to? It could be a checkbox on the responsive image style and image style entity forms to opt-in or opt-out?
Other improvements
These tasks above already seem quite actionable and provide quite significant improvements. Some other things that might even improve it more:
Comment #3
heddnI love the ideas expressed here. I even proposed it as an effort that _needs_ get done. However it wasn't sponsored at the time. Anything we can do to improve the UX/DX in this space would be GREAT.
If this is a meta/plan issue, we should start to link more items here. To that end, I've re-tagged as a plan and added references to:
Comment #4
catchThe responsive image configuration issues discussed in #2 are just about in the purview of field UX (given you end up selecting responsive images in field formatter configuration), so adding that tag.
https://github.com/whatwg/html/pull/8008 seems like it's starting to happen already, so we should definitely open an issue to support that, then we've got a chance of it working when the support is more widespread.
Comment #5
sam152 commentedI had a crack at something similar in contrib, yonks ago: https://www.drupal.org/project/responsive_image_automatic
Comment #6
lauriiiGlad to see this problem is being raised here. I've been in a several discussions where this has come up. Drupal Core Responsive Image module is really powerful but at the same it can be time consuming and complicated to configure it properly. I'm happy to support the efforts where needed to the extent I can. 😊
I've personally really enjoyed using Next.js Image plugin. It makes setting up and configuring responsive images really easy. It doesn't provide all of the flexibility that Drupal Responsive Images module provides, but maybe it's worth revisiting if we need all of that flexibility.
Comment #7
prudloff commentedWhat the webp support in core lacks is having an automatic jpeg/png fallback in picture tags for browsers that don't support WebP. (And the same logic could also apply to AVIF.)
The webp contrib module does that and #3213491: Add fallback format support to responsive images discusses adding this functionality to core.
Comment #8
catchThe fallback is less necessary for webp specifically because browser support is pretty much universal now, the last holdout I knew of was pre-2015 Macs, which also can't be detected via usage stats due to some weird decisions by the osx team. We decided that was an anomaly as far as #3275557: Add webp image conversion to core's install profile's image style was concerned so implemented default webp in the standard profile for 10.2.x
However, #3213491: Add fallback format support to responsive images will be useful for avif or any other new format that arises, so we should still try to add that.
Comment #9
andypostIn a perfect world the resulting image format should depend on image, webp vs avif - mostly always the later wins
Comment #10
dimiter commented@seanB, @GaëlG :
As of Drupal
10 (I think)9.2 according to @heddn in #3 above, Core is able to provide WebP support out-of-the-box for images styles. It is hidden away out of sight, so I do agree it is hard to find. To enable it, you have to add the 'Convert' action to an image style, and you will be able to select WebP as the desired format. I think that the fallback issue should still be solved in Core, but for now it seems that the https://www.drupal.org/project/wpf (WebP Fallback Image) module is able to handle that in a nice way without the need for additional configuration or setup. What I like about this approach is that the site will be serving WebP images by default, and will only need to do additional processing for the fallback images that are required.I do agree that it is pretty time-consuming nowadays to setup high-performance images using Core. The number of required images sizes will only grow over time (2x multiplier is already considered 'default' by now, 3x is already being used by modern iDevices but not often implemented, and its just a matter of time before the 4X multiplier will be introduced...) . If you would want to support all that for a full-width hero-image (which is a common use-case), also providing efficient images for use on mobile, you will already need quite some configuration and setup. Having something that makes this easier (e.g. the module mentioned/created by @seanB) would be much appreciated.
Comment #11
heddnDropping the notes from my research of the 2 modules I've come across that try to help in this space:
Are there other options to review? While rough, I really liked the simplicity of responsive_image_automatic. With a little bit of dusting off, I think it could really do a lot of things here.
Comment #12
milos.kroulik commentedThanks for the research. I've updated responsive_image_automatic module so I can test it in Drupal 10.1: https://github.com/miloskroulik/responsive_image_automatic.
Apart from missing multipliers, it (probably obviously) doesn't support lazy-loading of responsive images, which has been introduced in D 10.1.
Comment #13
heddnFollowing the work in that github repo.
Comment #14
milos.kroulik commentedThere's also another module - https://www.drupal.org/project/drimage, that seems to be very similar to https://www.drupal.org/project/easy_responsive_images:
But it provides an image field formatter, which makes the setup very quick.
I've done some basic testing - it seems to be working fine on the frontend, but JS file is currently not loading in the CKeditor (https://www.drupal.org/project/drimage/issues/3079190 - but it looks like there's some workaround).
Comment #15
heddnre #14: that looks pretty nice. I wish it would do its thing without js/css though. And it would support native/core webp instead of requiring a contrib module.
Comment #16
milos.kroulik commentedIt looks like there's a tradeoff - either you can generate images based on a static configuration (increases in viewport width), like responsive_image_automatic does or you need to use a JS to scale the image based on the dimensions of the container.
But I wonder, if it would make sense to generate the image styles and responsive image mappings automatically based on a "template" image style (which could for example define the webp conversion) and the theme.breakpoints.yml file. Actually, there are 2 modules which allow to create image styles programatically (https://www.drupal.org/project/image_styles_builder and https://www.drupal.org/project/image_style_generate) already.
Then again, it looks like there might a browser-based solution for container queries-based responsive images on the horizon: see https://www.stefanjudis.com/notes/should-responsive-images-work-with-con...
Comment #17
heddnFrom a predictability perspective, I'd want a starting place and some sizing parameters defined in the field formatter. I also want to be able to set all of this in the Node view mode (not in media view mode). It feels a little scary to have a module that automatically generates image styles without any limits. Could easily lead to a DDoS and filling up the disk.
I also want 1.5x, 2x, 3x and (soon) 4x image styles that increase the size of the image but also reduce the image quality to 50% or 30%.
All of this should put the experience of building styles for responsive images front and center. Maybe there could be some integration w/ https://ausi.github.io/respimagelint/ to instantly test the built styles?
Comment #18
catchFor configuration on the node view mode we'd need #2947796: Responsive image format for media.
For #16 something like that seems like a good idea. I think what you're suggesting is you start with one manually created image styles, and then responsive image module when you're creating a responsive style gives you the option to generate variations based on the same aspect ratios. It would allow for what srcset and sizes attributes can do. Completely manual configuration with different aspect ratios is still there either for different aspect ratios/cropping rules or just fine tuning.
Comment #19
dimiter commentedHow about an interface where instead of generating image styles, you can define aspect ratios to use (e.g. 1/1, 4/3, 16/9, etc). Then, for each aspect ratio, you can (manually) define the widths for which to generate image styles (e.g. 120px, 320px, 640px, 1200px, etc). Additionally, you could enter / select a range of multipliers (1x, 1.5x, 2x, 3x, 4x) to use. All that combined will result in a matrix that can generate all required image styles beforehand without the need for Javascript during runtime. Added benefit is that because the aspect ratio is the same, the image styles for the larger breakpoints can also be injected into the smaller breakpoint (e.g 2x 640x480 can also be used as 1x 1280x960).
This does allow the freedom to decide which breakpoints and image sizes to generate. Each of these entries could also have (some of the) effects applied to them. For example, the WebP transform or black/white effects could be applied without problem, but the various scale and/or resize-options wouldn’t work.
Comment #20
heddnI do like #19, but I have concerns about re-using image styles that are 1x in one place for 2x, 3x, etc in other places. The image quality for 2x and 3x doesn't need to be 80%+. A quality of 30-50% is sufficient. Because while mobile devices can render greater pixel density, the human eye cannot tell the difference between 30% 2x and 80% 2x and the size saving for a 2x 30% is significant enough to justify making a different image style.
Comment #21
dimiter commentedI hadn’t thought about that, seems to be a fair point (although I’m not sure if I would go as low as 30%, but that’s a concern for later).
While my suggestion from #19 is not yet what I would call ‘out of the box’, it would be much easier to configure for a large amount of image sizes/ratios. Of course, it would be possible to supply some (optional) default configuration, that e.g. provides the 4/3 ratio by default with some common used widths (320px … 1200px … 2500px?) in 1x and 2x multipliers, in WebP, that would improve the ‘out of the box’ experience for new setups.
Comment #22
gaëlgHello there, thank you all for the great feedback on this issue! It looks like many people are concerned and have ideas! :)
It may be the good time to start organizing a bit the various problems and ideas discussed here. It's look like there are 3 main questions.
1) What should be the decent/recommended/optimized/default way to display an image in HTML?
picture, source, srcset, sizes, image file formats, multipliers, image quality, breakpoints,... This issue in somewhat Drupal-agnostic, I guess we can get answers elsewhere on the web.
Avenues in comments #1, #4, #17, #20
See also:
https://www.stefanjudis.com/notes/should-responsive-images-work-with-con...
https://github.com/whatwg/html/pull/8008
https://ausi.github.io/respimagelint/docs.html
2) Which technical way to share/pool the creation and also the updates of many Drupal image derivatives needed for a same responsive image display, to get a better admin UX?
ImageStyleInterface should not extend ConfigEntityInterface? Or we should use config at the field formatter level and get rid of the Drupal "image style" concept?
Wizard à la Views?
I believe we need a clearer view in question 1 before going further with this.
Avenues in comments #1, #16, #17, #18, #19, #21
See also:
https://www.drupal.org/project/easy_responsive_images
https://www.drupal.org/project/responsive_image_automatic
https://www.drupal.org/project/drimage
https://www.drupal.org/project/image_styles_builder
https://www.drupal.org/project/image_style_generate
#2947796: Responsive image format for media
#2534058: [META] Usability of Responsive Image in Core
3) Webp and avif conversions by default in core, with fallbacks (at least for avif which is less supported for now)
This seems to be more a task than a question, as there is some consensus on what should be done (maybe not that much on how in should be done?). This is already a work in progress independently from this issue. There could be a follow-up to question 2 to handle question 3 in the new UX paradigm.
See also:
https://www.drupal.org/node/3171135
#3213491: Add fallback format support to responsive images
#3275557: Add webp image conversion to core's install profile's image style
#3282679: Allow user-uploaded WebP images everywhere in Drupal by default: image fields, media library, text editors
#3202016: Let GDToolkit support AVIF image format
https://www.drupal.org/project/wpf
and comment #9
So, do we make this issue a meta and create 3 children issues?
Comment #23
catchI don't think that needs revisiting here. Core responsive images module uses the picture element which has a superset of all the other methods. So they may be cases where it's overkill, but we'd always need to provide it unless browsers deprecate it. We could potentially look at alternative formatters/formatter configuration options when picture isn't needed but that doesn't feel necessary.
Comment #24
heddnGreat summary in #22. I think bullet 2 is key and will make/break responsive images. They are too hard to setup and manage, so they simply aren't used nearly enough.
Comment #25
seanbGreat ideas and discussions! Thanks everyone. I think it's definitely a good idea to start using this as a meta issue. We can discuss, share and track possible improvements here.
Some ideas for issues to start improving things:
All major browsers support it. Since AVIF is not supported by Edge, we need to check the HTTP_ACCEPT header which makes it harder to cache pages, so I suggest postponing that and add it later.
We could use #2534058: [META] Usability of Responsive Image in Core for this one (one idea to improve this can be found in #2)
imgtag with thesrcset/sizesattributesI definitely think we should consider supporting an
imgelement withsrcset/sizesattributes. All major browsers support it. My reasons for this are the following:pictureelement can make it harder to provide consistent theming and JavaScript.sizes="auto"feature. This would allow lazy-loaded images to load images based on their actual size, not the viewport size.picturethatsrcset/sizesdon't cover.For backwards compatibility, I like the idea of additional formatters for this.
sizes="auto"feature for lazy-loaded images in the new responsive image formatter.The spec has landed (https://github.com/whatwg/html/pull/8008). We should postpone this until all major browsers have implemented the feature, but this can definitely improve performance when entities might be rendered in different 1/2/3 column layouts (like block content or paragraphs).
https://bugs.chromium.org/p/chromium/issues/detail?id=1359051
https://bugzilla.mozilla.org/show_bug.cgi?id=1819581
https://bugs.webkit.org/show_bug.cgi?id=253143
Comment #26
prudloff commentedYou don't need to do this. If you generate a
picturetag with multiple formats, the browser will only load the AVIF file if it supports this format: https://avif.io/blog/tutorials/html/#implementationComment #27
gaëlg@catch #23: Sorry, I wasn't clear enough. Yes,
picture/sourcecan be useful because they allow for file type fallbacks, media queries (notably for art direction),... And even if apicturetag with only one childsourcetag can be simplified into animgtag, it's not necessary.I meant: what is a bit more controversial is: most of the time, to display an image (usually a photo), should we use:
- sizes?
- and/or media queries?
- and/or multipliers?
If we use srcset, which widths should be provided? Should we have a different image quality (I mean compression in %, not size in px) depending on the multiplier?
In other words: if I have a source image file and a desired aspect ratio, what should be the resulting HTML, by default in core? My current answer is in the issue summary, but I'm not sure it's the right one. I did not know about
sizes=autobut it looks great, as it prevents the need to set the right sizes value according to CSS, which can be difficult and can't be computed as a default.@heddn #24: Yes, the big need is point 2. But it's easier to discuss if we agree on point 1 before.
@seanB #25: This is now a meta issue :) But before creating most children issues for Drupal implementation tasks (I like your ideas), I think we need to agree on point 1.
@prudloff #26: Yup, there are two ways to serve image formats with fallbacks. One is to look at HTTP_ACCEPT header and serve a different HTML according to it. The other is to use a picture tag. The second one seems better to me because it eases caching. But this is one of the questions on which we should agree before we can set a default system.
Comment #28
gaëlgJust referencing this blog post which may help with step 1 of comment #22: https://mariohernandez.io/blog/responsive-images-in-drupal-a-guide/
I also talked to @nod_ which is Provisional Frontend Framework Manager and may help take a decision on step 1.
Comment #29
andypostComment #30
gaëlgComment #31
mgiffordGreat to see this.
This is how Wagtail is currently doing this:
https://wagtail.org/sustainability/
https://wagtail.org/blog/wagtail-greener-and-leaner/
Also an idea for relative CO2 impacts (all estimates of course):
https://sustainablescreen.org/unlocking-sustainable-speed-optimising-ima...
Comment #32
gaëlgThank you @mgifford. I can see that in Wagtail, they seem to have no default value for the sizes and srcset values. So it's up to the "site builder" to define the right values, which can be difficult. I guess in Drupal we should have a decent default, if possible.
https://docs.wagtail.org/en/stable/reference/jinja2.html#picture
Comment #33
rkollerOne idea I've posted over in the #sustainability-team channel on the Drupal Slack, and @catch suggested there to repost it in this issue as well.
There is the following linting tool: https://github.com/ausi/respimagelint which provides recommendations about the used image sizes as well as the syntax of
img srcsetand thepictureelement. I wonder for a while now if it wouldn't be possible to adjust the algorithm of respimagelint to enable Drupal Core to auto generate a list of image styles for the installed default theme? For the default theme you know all the breakpoints across viewports and the syntax for img srcset and the picture elements, shouldn't it then be possible, instead of just optimizing image sizes, to auto generate a list of image styles from the ground up? But I am not a developer therefore i am uncertain if that might be a reasonable approach?Comment #34
gaëlgI just read about the Starshot project. This issue could be related?
Comment #35
catchYes I think so too, it would be a good thing to add alongside a theme builder.
I also opened #3446582: Responsive images recipe a couple of days ago, to ship some default image styles matching Olivero's break points to start with and linked this issue from there too.
Comment #36
andypostComment #37
andypostwould be great to start adoption of AVIF as it saving disk and bandwidth
Comment #38
catchI think avif needs #3213491: Add fallback format support to responsive images unless it's already supported by all of Drupal's supported browsers.
Comment #39
mstrelan commented@catch I think all supported browsers are covered. https://caniuse.com/avif
It's just older Safari and IE that aren't. Pretty sure even Firefox ESR is good as that is at version 115.
Comment #40
catchOh interesting I didn't realise browser support was so far ahead of PHP support.
I think the next thing to figure out would be how to add avif conversion to image styles by default, but only when it's available on the server.
Do we need a new conversion that does avif if available, but falls back to webp if it's not? We could then update install profiles (and Drupal CMS) to use that?
Comment #41
mstrelan commentedThat sounds like a good idea. Actually I noticed Opera Mini is listed in our supported browsers and that doesn't support avif.
Comment #42
catchSo Opera Mini also doesn't support
pictureorsizeswhich means I think core's responsive image support already doesn't work with it, which would mean #3213491: Add fallback format support to responsive images also wouldn't work with it.But also Opera Mini usage is dropping:
It doesn't show up on the global statcounter charts, so I checked Nigeria which came up via a google search as having some opera mini usage.
Opera Mini 4.4 usage is 2.76% in Nigeria in 2024-2025: https://gs.statcounter.com/browser-version-market-share/all/nigeria/#mon...
This is down from 3.49% for Opera Mini 4.4 and 1.49% for Opera Mini 7.4 in 2022-2023 https://gs.statcounter.com/browser-version-market-share/all/nigeria/#mon...
So that's usage about halved in two years.
Given that, I think we could at least open an issue to discuss dropping support for Opera Mini in Drupal 12, and do all the steps except making it the default image style action in the standard profile in Drupal 11.
Comment #43
catchOpened #3510387: Replace "Opera Mini" with "Opera Mobile" in supported browsers
Comment #44
mstrelan commentedOpened #3510582: AVIF conversion with WEBP fallback
Comment #45
scott_euser commentedWhile AVIF is better for compression, I am finding it hard to come to a conclusion as to whether AVIF is a good recommendation vs WEBP purely from an environmental impact of power consumption perspective. I.e., the power needeed to compress/decompress WEBP seems to be compared to PNG, but all I can find is random blog posts without any quantitative analysis that keep saying AVIF compress/decompress is more expensive, outweighing the savings from reduced data transfer/bandwidth. I really find it hard to find anything conclusive though - has anyone else looked into it from that perspective?
Thanks!
Comment #46
andypostAVIF is expensive (x2-x3 vs WEBP on compression) so fits for hires images mostly
Comment #47
catch#3516434: Consider falling back to webp from AVIF based on filesize has a possible approach to the trade-offs between AVIF and webp for filesize.
Comment #48
gaëlgComment #49
mgifford@scott_euser here is some reason comparisons between the two:
All three articles agree that AVIF’s superior compression leads to smaller image file sizes, which can reduce bandwidth usage and potentially lower energy consumption during data transmission. However, AVIF’s increased decoding time may require more processing power on the client side, possibly offsetting some energy savings.
Comment #51
heddnhttps://gist.github.com/heddn/4c589071a0bcd13906c6cb6a7e9f2be6 => pretty rough plan at the moment. Claude helped me document some of my ideas in this space.
some recent issues/projects that have some bearing:
Comment #52
heddnComment #53
heddnComment #54
heddn