function image_effects_image_style_flush in Image Effects 8
Same name and namespace in other branches
- 8.3 image_effects.module \image_effects_image_style_flush()
- 8.2 image_effects.module \image_effects_image_style_flush()
Implements hook_image_style_flush().
This hook checks if the image style that is being flushed is used in any aspect switcher effect. If so, the style that contains the aspect switcher effect should be flushed as well.
File
- ./
image_effects.module, line 211 - Provides effects and operations for the Image API.
Code
function image_effects_image_style_flush(ImageStyle $style) {
// Retrieve image styles that have an aspect switcher effect that contains
// the style being flushed.
$query = \Drupal::entityQuery('image_style');
$query
->condition('effects.*.id', 'image_effects_aspect_switcher');
$group = $query
->orConditionGroup()
->condition('effects.*.data.landscape_image_style', $style
->id())
->condition('effects.*.data.portrait_image_style', $style
->id());
$image_style_ids = $query
->condition($group)
->execute();
// Flush them all.
foreach ($image_style_ids as $image_style_id) {
$image_style = ImageStyle::load($image_style_id);
$image_style
->flush();
}
}