image.drush.inc

  1. 8.0.x commands/core/image.drush.inc
  2. 6.x commands/core/image.drush.inc
  3. 7.x commands/core/image.drush.inc
  4. 4.x commands/core/image.drush.inc
  5. 5.x commands/core/image.drush.inc
  6. master commands/core/image.drush.inc

Image module's drush integration.

@todo image-build($field_name, $bundle, $style_name)

Functions

Namesort descending Description
drush_image_flush
drush_image_flush_all
image_drush_command Implementation of hook_drush_command().
image_image_flush_complete Command argument complete callback.

File

commands/core/image.drush.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Image module's drush integration.
  5. *
  6. * @todo image-build($field_name, $bundle, $style_name)
  7. */
  8. /**
  9. * Implementation of hook_drush_command().
  10. */
  11. function image_drush_command() {
  12. $items['image-flush'] = array(
  13. 'description' => 'Flush all derived images for a given style.',
  14. 'core' => array('7+'),
  15. 'drupal_dependencies' => array('image'),
  16. 'arguments' => array(
  17. 'style' => 'An image style machine name. If not provided, user may choose from a list of names.',
  18. ),
  19. 'options' => array(
  20. 'all' => 'Flush all derived images',
  21. ),
  22. 'examples' => array(
  23. 'drush image-flush' => 'Pick an image style and then delete its images.',
  24. 'drush image-flush thumbnail' => 'Delete all thumbnail images.',
  25. 'drush image-flush --all' => 'Flush all derived images. They will be regenerated on the fly.',
  26. ),
  27. );
  28. return $items;
  29. }
  30. /**
  31. * Command argument complete callback.
  32. *
  33. * @return
  34. * Array of available configuration files for editing.
  35. */
  36. function image_image_flush_complete() {
  37. drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
  38. return array('values' => array_keys(image_styles()));
  39. }
  40. function drush_image_flush($style_name = NULL) {
  41. if (drush_get_option('all')) {
  42. drush_image_flush_all();
  43. }
  44. elseif (empty($style_name)) {
  45. $choices = drupal_map_assoc(array_keys(image_styles()));
  46. $choices = array_merge(array('all' => 'all'), $choices);
  47. $style_name = drush_choice($choices, dt("Choose a style to flush."));
  48. if ($style_name == 'all') {
  49. drush_image_flush_all();
  50. }
  51. else {
  52. return drush_invoke('image-flush', array($style_name));
  53. }
  54. }
  55. else {
  56. if ($style = image_style_load($style_name)) {
  57. image_style_flush($style);
  58. drush_log(dt('Image style !style_name flushed', array('!style_name' => $style_name)), 'success');
  59. }
  60. else {
  61. return drush_set_error(dt('Image style !style not recognized.', array('!style' => $style_name)));
  62. }
  63. }
  64. }
  65. function drush_image_flush_all() {
  66. foreach (image_styles() as $style) {
  67. image_style_flush($style);
  68. }
  69. drush_log(dt('All image styles flushed'), 'success');
  70. }