3 namespace Drupal\image;
5 use Drupal\Component\Plugin\ConfigurablePluginInterface;
6 use Drupal\Component\Plugin\PluginInspectionInterface;
7 use Drupal\Core\Image\ImageInterface;
10 * Defines the interface for image effects.
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
19 interface ImageEffectInterface extends PluginInspectionInterface, ConfigurablePluginInterface {
22 * Applies an image effect to the image object.
24 * @param \Drupal\Core\Image\ImageInterface $image
25 * An image file object.
28 * TRUE on success. FALSE if unable to perform the image effect on the image.
30 public function applyEffect(ImageInterface $image);
33 * Determines the dimensions of the styled image.
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.
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
50 public function transformDimensions(array &$dimensions, $uri);
53 * Returns the extension the derivative would have have after applying this
56 * @param string $extension
57 * The file extension the derivative has before applying.
60 * The file extension after applying.
62 public function getDerivativeExtension($extension);
65 * Returns a render array summarizing the configuration of the image effect.
70 public function getSummary();
73 * Returns the image effect label.
76 * The image effect label.
78 public function label();
81 * Returns the unique ID representing the image effect.
84 * The image effect ID.
86 public function getUuid();
89 * Returns the weight of the image effect.
92 * Either the integer weight of the image effect, or an empty string.
94 public function getWeight();
97 * Sets the weight for this image effect.
100 * The weight for this image effect.
104 public function setWeight($weight);