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. 'arguments' => array(
  16. 'style' => 'An image style machine name. If not provided, user may choose from a list of names.',
  17. ),
  18. 'options' => array(
  19. 'all' => 'Flush all derived images',
  20. ),
  21. 'examples' => array(
  22. 'drush image-flush' => 'Pick an image style and then delete its images.',
  23. 'drush image-flush thumbnail' => 'Delete all thumbnail images.',
  24. 'drush image-flush --all' => 'Flush all derived images. They will be regenerated on the fly.',
  25. ),
  26. );
  27. return $items;
  28. }
  29. /**
  30. * Command argument complete callback.
  31. *
  32. * @return
  33. * Array of available configuration files for editing.
  34. */
  35. function image_image_flush_complete() {
  36. drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
  37. return array('values' => array_keys(image_styles()));
  38. }
  39. function drush_image_flush($style_name = NULL) {
  40. if (drush_get_option('all')) {
  41. drush_image_flush_all();
  42. }
  43. elseif (empty($style_name)) {
  44. $choices = drupal_map_assoc(array_keys(image_styles()));
  45. $choices = array_merge(array('all' => 'all'), $choices);
  46. $style_name = drush_choice($choices, dt("Choose a style to flush."));
  47. if ($style_name == 'all') {
  48. drush_image_flush_all();
  49. }
  50. else {
  51. return drush_invoke('image-flush', array($style_name));
  52. }
  53. }
  54. else {
  55. if ($style = image_style_load($style_name)) {
  56. image_style_flush($style);
  57. drush_log(dt('Image style !style_name flushed', array('!style_name' => $style_name)), 'success');
  58. }
  59. else {
  60. return drush_set_error(dt('Image style !style not recognized.', array('!style' => $style_name)));
  61. }
  62. }
  63. }
  64. function drush_image_flush_all() {
  65. foreach (image_styles() as $style) {
  66. image_style_flush($style);
  67. }
  68. drush_log(dt('All image styles flushed'), 'success');
  69. }