Problem/Motivation
ImageUrlFormatter (plugin ID: image_url) does not override calculateDependencies() or onDependencyRemoval(). This means that when a view display or entity view display uses the image_url formatter with a configured image style, the image style is not declared as a config dependency.
As a consequence:
- Deleting the referenced image style is not blocked by Drupal's dependency system
- No cascade update occurs (e.g., falling back to no style) when the image style is removed
- Programmatic re-save of the entity view display via
drush config:exportsilently drops the image style from thedependencies.configlist, even though the formatter still references it in its settings
How it was discovered
During a config normalization pass (programmatic re-save of all config entities followed by config export), a core.entity_view_display for a block content type lost image.style.front_carousel from its dependencies.config section — despite the formatter explicitly referencing that image style in its settings.image_style key:
content:
field_banner_hatterkep:
type: image_url # ← this formatter
label: hidden
settings:
image_style: front_carousel # ← references the image style
Manually re-saving the display through the admin UI (/admin/structure/block-content/manage/banner/display) confirmed the same result: the image style dependency is never computed.
Root cause
The inheritance chain is:
PluginSettingsBase (has generic calculateDependencies — returns empty)
└─ ImageFormatterBase (no override)
├─ ImageFormatter (overrides calculateDependencies + onDependencyRemoval ✅)
└─ ImageUrlFormatter (no override ❌)
ImageFormatter correctly overrides calculateDependencies() to add the image style as a config dependency, and onDependencyRemoval() to handle style deletion gracefully. However, both methods live on ImageFormatter itself — not on the shared ImageFormatterBase. So ImageUrlFormatter, which also extends ImageFormatterBase and also has an image_style setting, inherits only the generic no-op from PluginSettingsBase.
History
This was identified during the original review of ImageUrlFormatter in #2517030:
- Comment #7 (mondrake): flagged the missing dependency, referencing #2479487
- Comment #75 (mondrake): "Shouldn't
ImageFormatter::calculateDependencies()andImageFormatter::onDependencyRemoval()just
introduced in #2479487 be also moved toImageFormatterBase?" - Comment #77 (amateescu): claimed it was addressed in a patch revision
The fix was never committed. The current code in Drupal 11.x still has both methods exclusively on ImageFormatter only.
Proposed resolution
Move calculateDependencies() and onDependencyRemoval() from ImageFormatter to ImageFormatterBase, so that all
formatters extending it (including ImageUrlFormatter and any future subclasses) automatically declare the image style dependency.
Remaining tasks
- Move the two methods to
ImageFormatterBase - Add a kernel test asserting that
ImageUrlFormatterdeclares the image style dependency - Verify
ResponsiveImageFormatteris not affected (it has its own override)
Versions affected
All versions since ImageUrlFormatter was added to core (Drupal 10.1+ through current 11.x).
(Issue summarized with the use of Claude Opus 4.6)
Comments
Comment #2
quietone commented@baluertl, The issue summary reads like it was generated using an AI tool. The policy on the use of AI when contributing to Drupal includes that the use of AI must be disclosed. I suggest reading that to be aware of the expectations of the Drupal community and the consequences for violations of the policy.
Issues for Drupal core should be targeted to the 'main' branch, our primary development branch. Changes are made on the main branch first, and are then back ported as needed according to the Core change policies. The version the problem was discovered on should be stated in the issue summary Problem/Motivation section. Thanks.
Comment #3
baluertlquietone Indeed, I used Claude to summarize the issue. Thanks for pointing out the community guideline; I was unaware of its existence at all.