image_7.inc

  1. 8.0.x commands/core/drupal/image_7.inc
  2. 7.x commands/core/drupal/image_7.inc
  3. master commands/core/drupal/image_7.inc

Specific functions for a Drupal image handling. drush_include_engine() magically includes either this file or image_X.inc depending on which version of Drupal is in use.

Functions

File

commands/core/drupal/image_7.inc
View source
  1. <?php
  2. use Drush\Log\LogLevel;
  3. /**
  4. * @file
  5. * Specific functions for a Drupal image handling.
  6. * drush_include_engine() magically includes either this file
  7. * or image_X.inc depending on which version of Drupal
  8. * is in use.
  9. */
  10. function drush_image_styles() {
  11. return image_styles();
  12. }
  13. function drush_image_style_load($style_name) {
  14. return image_style_load($style_name);
  15. }
  16. function drush_image_flush_single($style_name) {
  17. if ($style = image_style_load($style_name)) {
  18. image_style_flush($style);
  19. drush_log(dt('Image style !style_name flushed', array('!style_name' => $style_name)), LogLevel::SUCCESS);
  20. }
  21. }
  22. /*
  23. * Command callback. Create an image derivative.
  24. *
  25. * @param string $style_name
  26. * The name of an image style.
  27. *
  28. * @param string $source
  29. * The path to a source image, relative to Drupal root.
  30. */
  31. function _drush_image_derive($style_name, $source) {
  32. $image_style = image_style_load($style_name);
  33. $scheme = file_default_scheme();
  34. $image_uri = $scheme . '://' . $source;
  35. $derivative_uri = image_style_path($image_style['name'], $image_uri);
  36. if (image_style_create_derivative($image_style, $source, $derivative_uri)) {
  37. return $derivative_uri;
  38. }
  39. }