353233246e3f9ca29eb7ba21e0e815907f704dbd
[yaffs-website] / vendor / drush / drush / commands / core / drupal / image.inc
1 <?php
2
3 use Drush\Log\LogLevel;
4
5 /**
6  * @file
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
10  *   is in use.
11  */
12
13 function drush_image_styles() {
14   return \Drupal::entityManager()->getStorage('image_style')->loadMultiple();
15 }
16
17 function drush_image_style_load($style_name) {
18   return \Drupal::entityManager()->getStorage('image_style')->load($style_name);
19 }
20
21 function drush_image_flush_single($style_name) {
22   if ($style = drush_image_style_load($style_name)) {
23     $style->flush();
24     drush_log(dt('Image style !style_name flushed', array('!style_name' => $style_name)), LogLevel::SUCCESS);
25   }
26 }
27
28 /*
29  * Command callback. Create an image derivative.
30  *
31  * @param string $style_name
32  *   The name of an image style.
33  *
34  * @param string $source
35  *   The path to a source image, relative to Drupal root.
36  */
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;
42   }
43 }