comparison core/modules/image/src/ImageEffectInterface.php @ 0:4c8ae668cc8c

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