image.api.php 1.17 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
<?php

/**
 * @file
 * Hooks related to image styles and effects.
 */

/**
 * @addtogroup hooks
 * @{
 */

/**
14
 * Alter the information provided in \Drupal\image\Annotation\ImageEffect.
15 16 17 18 19
 *
 * @param $effects
 *   The array of image effects, keyed on the machine-readable effect name.
 */
function hook_image_effect_info_alter(&$effects) {
20 21
  // Override the Image module's 'Scale and Crop' effect label.
  $effects['image_scale_and_crop']['label'] = t('Bangers and Mash');
22 23
}

24 25 26 27 28 29 30
/**
 * 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,
31
 * deleted, or any effect associated with the style is update or deleted.
32
 *
33 34
 * @param \Drupal\image\ImageStyleInterface $style
 *   The image style object that is being flushed.
35 36 37
 */
function hook_image_style_flush($style) {
  // Empty cached data that contains information about the style.
38
  \Drupal::cache('mymodule')->deleteAll();
39
}
40

41 42 43
/**
 * @} End of "addtogroup hooks".
 */