image.api.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * @file
  4. * Hooks related to image styles and effects.
  5. */
  6. /**
  7. * @addtogroup hooks
  8. * @{
  9. */
  10. /**
  11. * Alter the information provided in \Drupal\image\Annotation\ImageEffect.
  12. *
  13. * @param $effects
  14. * The array of image effects, keyed on the machine-readable effect name.
  15. */
  16. function hook_image_effect_info_alter(&$effects) {
  17. // Override the Image module's 'Scale and Crop' effect label.
  18. $effects['image_scale_and_crop']['label'] = t('Bangers and Mash');
  19. }
  20. /**
  21. * Respond to image style flushing.
  22. *
  23. * This hook enables modules to take effect when a style is being flushed (all
  24. * images are being deleted from the server and regenerated). Any
  25. * module-specific caches that contain information related to the style should
  26. * be cleared using this hook. This hook is called whenever a style is updated,
  27. * deleted, or any effect associated with the style is update or deleted.
  28. *
  29. * @param \Drupal\image\ImageStyleInterface $style
  30. * The image style object that is being flushed.
  31. */
  32. function hook_image_style_flush($style) {
  33. // Empty cached data that contains information about the style.
  34. \Drupal::cache('mymodule')->deleteAll();
  35. }
  36. /**
  37. * @} End of "addtogroup hooks".
  38. */