3 use Drush\Log\LogLevel;
7 * Specific functions for a Drupal image handling.
8 * drush_include_engine() magically includes either this file
9 * or image_X.inc depending on which version of Drupal
13 function drush_image_styles() {
14 return \Drupal::entityManager()->getStorage('image_style')->loadMultiple();
17 function drush_image_style_load($style_name) {
18 return \Drupal::entityManager()->getStorage('image_style')->load($style_name);
21 function drush_image_flush_single($style_name) {
22 if ($style = drush_image_style_load($style_name)) {
24 drush_log(dt('Image style !style_name flushed', array('!style_name' => $style_name)), LogLevel::SUCCESS);
29 * Command callback. Create an image derivative.
31 * @param string $style_name
32 * The name of an image style.
34 * @param string $source
35 * The path to a source image, relative to Drupal root.
37 function _drush_image_derive($style_name, $source) {
38 $image_style = drush_image_style_load($style_name);
39 $derivative_uri = $image_style->buildUri($source);
40 if ($image_style->createDerivative($source, $derivative_uri)) {
41 return $derivative_uri;