Created on 14 June 2016, about 8 years ago
Updated 30 June 2023, 12 months ago

Problem/Motivation

The imagecache_actions module had a action to perform different actions based on the aspect ratioo:

Aspect Switcher - lets you perform different actions or use different dimensions based on whether the image is 'landscape' or 'portrait'

It would be nice to have this in D8.

Proposed resolution

1) Implement the image effect plugin;

2) Implement hook_ENTITY_TYPE_presave() for image_style entities, so that when an image style is saved, it checks if there are image_effects_aspect_switcher effects in it, and if so checks that the effect configuration is not self-referencing the image style itself as either 'landscape' or 'portrait' child style, that would cause hard to recover issues with the config dependency management system. In this case an appropriate ConfigValueException is thrown;

3) Implement hook_image_style_flush(), so that when an image style is flushed, also any other image style containing an image_effects_aspect_switcher that references that image style gets flushed too. Since we are loading the dependent image styles and executing their ::flush method, we also invalidate the render caches of any parent image style (ImageStyle::flush calls Cache::invalidateTags($this->getCacheTagsToInvalidate()))

Remaining tasks

  • review, test, commit
  • maybe file a followup issue for Drupal core so that if ImageStyle::save throws an exception, this is captured by form code and rendered to the user as a message - now it will lead to WSOD

User interface changes

none

API changes

none

Data model changes

none

✨ Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland Lukas von Blarer

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States bsnodgrass

    Can someone confirm this was actually fixed and committed? The issue summary indicates it was yet to be committed, and the issue was automatically closed.

    There are child issues still open.

Production build 0.69.0 2024