annotate core/modules/image/src/ImageEffectInterface.php @ 19:fa3358dc1485 tip

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