image_example.install 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * @file
  4. * Install, update, and uninstall functions for the image_example module.
  5. */
  6. /**
  7. * Implements hook_install().
  8. *
  9. * @ingroup image_example
  10. */
  11. function image_example_install() {
  12. // Set a variable containing the name of the style to use when the module
  13. // outputs an image.
  14. variable_set('image_example_style_name', 'image_example_style');
  15. }
  16. /**
  17. * Implements hook_uninstall().
  18. *
  19. * @ingroup image_example
  20. */
  21. function image_example_uninstall() {
  22. variable_del('image_example_style_name');
  23. variable_del('image_example_image_fid');
  24. }
  25. /**
  26. * Implements hook_enable().
  27. *
  28. * @ingroup image_example
  29. */
  30. function image_example_enable() {
  31. // There is currently no way to manually flush an image style which causes
  32. // problems when installing a new module that implements
  33. // hook_image_styles_alter(). If the new module modifies an image style that
  34. // modification will not be applied to any images that have already been
  35. // generated unless the styles are flushed. This is one way around that.
  36. $styles = image_styles();
  37. foreach ($styles as $style) {
  38. image_style_flush($style);
  39. }
  40. }
  41. /**
  42. * Implements hook_disable().
  43. *
  44. * @ingroup image_example
  45. */
  46. function image_example_disable() {
  47. // Solves the same problem as image_example_enable().
  48. image_example_enable();
  49. }