Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\image;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Component\Plugin\ConfigurablePluginInterface;
|
Chris@0
|
6 use Drupal\Component\Plugin\PluginInspectionInterface;
|
Chris@0
|
7 use Drupal\Core\Image\ImageInterface;
|
Chris@0
|
8
|
Chris@0
|
9 /**
|
Chris@0
|
10 * Defines the interface for image effects.
|
Chris@0
|
11 *
|
Chris@0
|
12 * @see \Drupal\image\Annotation\ImageEffect
|
Chris@0
|
13 * @see \Drupal\image\ImageEffectBase
|
Chris@0
|
14 * @see \Drupal\image\ConfigurableImageEffectInterface
|
Chris@0
|
15 * @see \Drupal\image\ConfigurableImageEffectBase
|
Chris@0
|
16 * @see \Drupal\image\ImageEffectManager
|
Chris@0
|
17 * @see plugin_api
|
Chris@0
|
18 */
|
Chris@0
|
19 interface ImageEffectInterface extends PluginInspectionInterface, ConfigurablePluginInterface {
|
Chris@0
|
20
|
Chris@0
|
21 /**
|
Chris@0
|
22 * Applies an image effect to the image object.
|
Chris@0
|
23 *
|
Chris@0
|
24 * @param \Drupal\Core\Image\ImageInterface $image
|
Chris@0
|
25 * An image file object.
|
Chris@0
|
26 *
|
Chris@0
|
27 * @return bool
|
Chris@0
|
28 * TRUE on success. FALSE if unable to perform the image effect on the image.
|
Chris@0
|
29 */
|
Chris@0
|
30 public function applyEffect(ImageInterface $image);
|
Chris@0
|
31
|
Chris@0
|
32 /**
|
Chris@0
|
33 * Determines the dimensions of the styled image.
|
Chris@0
|
34 *
|
Chris@0
|
35 * @param array &$dimensions
|
Chris@0
|
36 * Dimensions to be modified - an array with the following keys:
|
Chris@0
|
37 * - width: the width in pixels, or NULL if unknown
|
Chris@0
|
38 * - height: the height in pixels, or NULL if unknown
|
Chris@0
|
39 * When either of the dimensions are NULL, the corresponding HTML attribute
|
Chris@0
|
40 * will be omitted when an image style using this image effect is used.
|
Chris@0
|
41 * @param string $uri
|
Chris@0
|
42 * Original image file URI. It is passed in to allow an effect to
|
Chris@0
|
43 * optionally use this information to retrieve additional image metadata
|
Chris@0
|
44 * to determine dimensions of the styled image.
|
Chris@0
|
45 * ImageEffectInterface::transformDimensions key objective is to calculate
|
Chris@0
|
46 * styled image dimensions without performing actual image operations, so
|
Chris@0
|
47 * be aware that performing IO on the URI may lead to decrease in
|
Chris@0
|
48 * performance.
|
Chris@0
|
49 */
|
Chris@0
|
50 public function transformDimensions(array &$dimensions, $uri);
|
Chris@0
|
51
|
Chris@0
|
52 /**
|
Chris@0
|
53 * Returns the extension of the derivative after applying this image effect.
|
Chris@0
|
54 *
|
Chris@0
|
55 * @param string $extension
|
Chris@0
|
56 * The file extension the derivative has before applying.
|
Chris@0
|
57 *
|
Chris@0
|
58 * @return string
|
Chris@0
|
59 * The file extension after applying.
|
Chris@0
|
60 */
|
Chris@0
|
61 public function getDerivativeExtension($extension);
|
Chris@0
|
62
|
Chris@0
|
63 /**
|
Chris@0
|
64 * Returns a render array summarizing the configuration of the image effect.
|
Chris@0
|
65 *
|
Chris@0
|
66 * @return array
|
Chris@0
|
67 * A render array.
|
Chris@0
|
68 */
|
Chris@0
|
69 public function getSummary();
|
Chris@0
|
70
|
Chris@0
|
71 /**
|
Chris@0
|
72 * Returns the image effect label.
|
Chris@0
|
73 *
|
Chris@0
|
74 * @return string
|
Chris@0
|
75 * The image effect label.
|
Chris@0
|
76 */
|
Chris@0
|
77 public function label();
|
Chris@0
|
78
|
Chris@0
|
79 /**
|
Chris@0
|
80 * Returns the unique ID representing the image effect.
|
Chris@0
|
81 *
|
Chris@0
|
82 * @return string
|
Chris@0
|
83 * The image effect ID.
|
Chris@0
|
84 */
|
Chris@0
|
85 public function getUuid();
|
Chris@0
|
86
|
Chris@0
|
87 /**
|
Chris@0
|
88 * Returns the weight of the image effect.
|
Chris@0
|
89 *
|
Chris@0
|
90 * @return int|string
|
Chris@0
|
91 * Either the integer weight of the image effect, or an empty string.
|
Chris@0
|
92 */
|
Chris@0
|
93 public function getWeight();
|
Chris@0
|
94
|
Chris@0
|
95 /**
|
Chris@0
|
96 * Sets the weight for this image effect.
|
Chris@0
|
97 *
|
Chris@0
|
98 * @param int $weight
|
Chris@0
|
99 * The weight for this image effect.
|
Chris@0
|
100 *
|
Chris@0
|
101 * @return $this
|
Chris@0
|
102 */
|
Chris@0
|
103 public function setWeight($weight);
|
Chris@0
|
104
|
Chris@0
|
105 }
|