Mercurial > hg > isophonics-drupal-site
comparison core/modules/image/src/ImageStyleInterface.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\image; | |
4 | |
5 use Drupal\Core\Config\Entity\ConfigEntityInterface; | |
6 | |
7 /** | |
8 * Provides an interface defining an image style entity. | |
9 */ | |
10 interface ImageStyleInterface extends ConfigEntityInterface { | |
11 | |
12 /** | |
13 * Returns the replacement ID. | |
14 * | |
15 * @return string|null | |
16 * The replacement image style ID or NULL if no replacement has been | |
17 * selected. | |
18 * | |
19 * @deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.x. Use | |
20 * \Drupal\image\ImageStyleStorageInterface::getReplacementId() instead. | |
21 * | |
22 * @see \Drupal\image\ImageStyleStorageInterface::getReplacementId() | |
23 */ | |
24 public function getReplacementID(); | |
25 | |
26 /** | |
27 * Returns the image style. | |
28 * | |
29 * @return string | |
30 * The name of the image style. | |
31 */ | |
32 public function getName(); | |
33 | |
34 /** | |
35 * Sets the name of the image style. | |
36 * | |
37 * @param string $name | |
38 * The name of the image style. | |
39 * | |
40 * @return \Drupal\image\ImageStyleInterface | |
41 * The class instance this method is called on. | |
42 */ | |
43 public function setName($name); | |
44 | |
45 | |
46 /** | |
47 * Returns the URI of this image when using this style. | |
48 * | |
49 * The path returned by this function may not exist. The default generation | |
50 * method only creates images when they are requested by a user's browser. | |
51 * Modules may implement this method to decide where to place derivatives. | |
52 * | |
53 * @param string $uri | |
54 * The URI or path to the original image. | |
55 * | |
56 * @return string | |
57 * The URI to the image derivative for this style. | |
58 */ | |
59 public function buildUri($uri); | |
60 | |
61 /** | |
62 * Returns the URL of this image derivative for an original image path or URI. | |
63 * | |
64 * @param string $path | |
65 * The path or URI to the original image. | |
66 * @param mixed $clean_urls | |
67 * (optional) Whether clean URLs are in use. | |
68 * | |
69 * @return string | |
70 * The absolute URL where a style image can be downloaded, suitable for use | |
71 * in an <img> tag. Requesting the URL will cause the image to be created. | |
72 * | |
73 * @see \Drupal\image\Controller\ImageStyleDownloadController::deliver() | |
74 * @see file_url_transform_relative() | |
75 */ | |
76 public function buildUrl($path, $clean_urls = NULL); | |
77 | |
78 /** | |
79 * Generates a token to protect an image style derivative. | |
80 * | |
81 * This prevents unauthorized generation of an image style derivative, | |
82 * which can be costly both in CPU time and disk space. | |
83 * | |
84 * @param string $uri | |
85 * The URI of the original image of this style. | |
86 * | |
87 * @return string | |
88 * An eight-character token which can be used to protect image style | |
89 * derivatives against denial-of-service attacks. | |
90 */ | |
91 public function getPathToken($uri); | |
92 | |
93 /** | |
94 * Flushes cached media for this style. | |
95 * | |
96 * @param string $path | |
97 * (optional) The original image path or URI. If it's supplied, only this | |
98 * image derivative will be flushed. | |
99 * | |
100 * @return $this | |
101 */ | |
102 public function flush($path = NULL); | |
103 | |
104 /** | |
105 * Creates a new image derivative based on this image style. | |
106 * | |
107 * Generates an image derivative applying all image effects and saving the | |
108 * resulting image. | |
109 * | |
110 * @param string $original_uri | |
111 * Original image file URI. | |
112 * @param string $derivative_uri | |
113 * Derivative image file URI. | |
114 * | |
115 * @return bool | |
116 * TRUE if an image derivative was generated, or FALSE if the image | |
117 * derivative could not be generated. | |
118 */ | |
119 public function createDerivative($original_uri, $derivative_uri); | |
120 | |
121 /** | |
122 * Determines the dimensions of this image style. | |
123 * | |
124 * Stores the dimensions of this image style into $dimensions associative | |
125 * array. Implementations have to provide at least values to next keys: | |
126 * - width: Integer with the derivative image width. | |
127 * - height: Integer with the derivative image height. | |
128 * | |
129 * @param array $dimensions | |
130 * Associative array passed by reference. Implementations have to store the | |
131 * resulting width and height, in pixels. | |
132 * @param string $uri | |
133 * Original image file URI. It is passed in to allow effects to | |
134 * optionally use this information to retrieve additional image metadata | |
135 * to determine dimensions of the styled image. | |
136 * ImageStyleInterface::transformDimensions key objective is to calculate | |
137 * styled image dimensions without performing actual image operations, so | |
138 * be aware that performing IO on the URI may lead to decrease in | |
139 * performance. | |
140 * | |
141 * @see ImageEffectInterface::transformDimensions | |
142 */ | |
143 public function transformDimensions(array &$dimensions, $uri); | |
144 | |
145 /** | |
146 * Determines the extension of the derivative without generating it. | |
147 * | |
148 * @param string $extension | |
149 * The file extension of the original image. | |
150 * | |
151 * @return string | |
152 * The extension the derivative image will have, given the extension of the | |
153 * original. | |
154 */ | |
155 public function getDerivativeExtension($extension); | |
156 | |
157 /** | |
158 * Returns a specific image effect. | |
159 * | |
160 * @param string $effect | |
161 * The image effect ID. | |
162 * | |
163 * @return \Drupal\image\ImageEffectInterface | |
164 * The image effect object. | |
165 */ | |
166 public function getEffect($effect); | |
167 | |
168 /** | |
169 * Returns the image effects for this style. | |
170 * | |
171 * @return \Drupal\image\ImageEffectPluginCollection|\Drupal\image\ImageEffectInterface[] | |
172 * The image effect plugin collection. | |
173 */ | |
174 public function getEffects(); | |
175 | |
176 /** | |
177 * Saves an image effect for this style. | |
178 * | |
179 * @param array $configuration | |
180 * An array of image effect configuration. | |
181 * | |
182 * @return string | |
183 * The image effect ID. | |
184 */ | |
185 public function addImageEffect(array $configuration); | |
186 | |
187 /** | |
188 * Deletes an image effect from this style. | |
189 * | |
190 * @param \Drupal\image\ImageEffectInterface $effect | |
191 * The image effect object. | |
192 * | |
193 * @return $this | |
194 */ | |
195 public function deleteImageEffect(ImageEffectInterface $effect); | |
196 | |
197 /** | |
198 * Determines if this style can be applied to a given image. | |
199 * | |
200 * @param string $uri | |
201 * The URI of the image. | |
202 * | |
203 * @return bool | |
204 * TRUE if the image is supported, FALSE otherwise. | |
205 */ | |
206 public function supportsUri($uri); | |
207 | |
208 } |