Same name and namespace in other branches
  1. 7.x modules/image/image.api.php \hook_image_style_flush()
  2. 8.9.x core/modules/image/image.api.php \hook_image_style_flush()
  3. 9 core/modules/image/image.api.php \hook_image_style_flush()

Respond to image style flushing.

This hook enables modules to take effect when a style is being flushed (all images are being deleted from the server and regenerated). Any module-specific caches that contain information related to the style should be cleared using this hook. This hook is called whenever a style is updated, deleted, or any effect associated with the style is update or deleted.

Parameters

\Drupal\image\ImageStyleInterface $style: The image style object that is being flushed.

string|null $path: (optional) The original image path or URI. If it's supplied, only this image derivative will be flushed.

Related topics

1 function implements hook_image_style_flush()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

image_module_test_image_style_flush in core/modules/image/tests/modules/image_module_test/image_module_test.module
Implements hook_image_style_flush().
1 invocation of hook_image_style_flush()
ImageStyle::flush in core/modules/image/src/Entity/ImageStyle.php
Flushes cached media for this style.

File

core/modules/image/image.api.php, line 39
Hooks related to image styles and effects.

Code

function hook_image_style_flush($style, $path = NULL) {

  // Empty cached data that contains information about the style.
  \Drupal::cache('my_module')
    ->deleteAll();
}