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

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. function drush_image_flush($style_name = NULL) {
  31. if (drush_get_option('all')) {
  32. drush_image_flush_all();
  33. }
  34. elseif (empty($style_name)) {
  35. $choices = drupal_map_assoc(array_keys(image_styles()));
  36. $choices = array_merge(array('all' => 'all'), $choices);
  37. $style_name = drush_choice($choices, dt("Choose a style to flush."));
  38. if ($style_name == 'all') {
  39. drush_image_flush_all();
  40. }
  41. else {
  42. $commands = drush_get_commands();
  43. return drush_dispatch($commands['image-flush'], array($style_name));
  44. }
  45. }
  46. else {
  47. if ($style = image_style_load($style_name)) {
  48. image_style_flush($style);
  49. drush_log(dt('Image style !style_name flushed', array('!style_name' => $style_name)), 'success');
  50. }
  51. else {
  52. return drush_set_error(dt('Image style !style not recognized.', array('!style' => $style_name)));
  53. }
  54. }
  55. }
  56. function drush_image_flush_all() {
  57. foreach (image_styles() as $style) {
  58. image_style_flush($style);
  59. }
  60. drush_log(dt('All image styles flushed'), 'success');
  61. }