bcf1198ccfdaee242bd2740259c2bd69257ef3a1
[yaffs-website] / vendor / drush / drush / commands / core / drupal / image_7.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 image_styles();
15 }
16
17 function drush_image_style_load($style_name) {
18   return image_style_load($style_name);
19 }
20
21 function drush_image_flush_single($style_name) {
22   if ($style = image_style_load($style_name)) {
23     image_style_flush($style);
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 = image_style_load($style_name);
39   $scheme = file_default_scheme();
40   $image_uri = $scheme . '://' . $source;
41   $derivative_uri = image_style_path($image_style['name'], $image_uri);
42   if (image_style_create_derivative($image_style, $source, $derivative_uri)) {
43     return $derivative_uri;
44   }
45 }