interface ImageEffectInterface implements PluginInspectionInterface, ConfigurableInterface, DependentPluginInterface (View source)

Defines the interface for image effects.

Methods

string
getPluginId()

Gets the plugin_id of the plugin instance.

array
getPluginDefinition()

Gets the definition of the plugin implementation.

array
getConfiguration()

Gets this plugin's configuration.

setConfiguration(array $configuration)

Sets the configuration for this plugin instance.

array
defaultConfiguration()

Gets default configuration for this plugin.

array
calculateDependencies()

Calculates dependencies for the configured plugin.

bool
applyEffect(ImageInterface $image)

Applies an image effect to the image object.

transformDimensions(array $dimensions, string $uri)

Determines the dimensions of the styled image.

string
getDerivativeExtension(string $extension)

Returns the extension of the derivative after applying this image effect.

array
getSummary()

Returns a render array summarizing the configuration of the image effect.

string
label()

Returns the image effect label.

string
getUuid()

Returns the unique ID representing the image effect.

int|string
getWeight()

Returns the weight of the image effect.

$this
setWeight(int $weight)

Sets the weight for this image effect.

Details

string getPluginId()

Gets the plugin_id of the plugin instance.

Return Value

string

The plugin_id of the plugin instance.

array getPluginDefinition()

Gets the definition of the plugin implementation.

Return Value

array

The plugin definition, as returned by the discovery object used by the plugin manager.

array getConfiguration()

Gets this plugin's configuration.

Return Value

array

An array of this plugin's configuration.

setConfiguration(array $configuration)

Sets the configuration for this plugin instance.

Parameters

array $configuration

An associative array containing the plugin's configuration.

array defaultConfiguration()

Gets default configuration for this plugin.

Return Value

array

An associative array with the default configuration.

array calculateDependencies()

Calculates dependencies for the configured plugin.

Dependencies are saved in the plugin's configuration entity and are used to determine configuration synchronization order. For example, if the plugin integrates with specific user roles, this method should return an array of dependencies listing the specified roles.

Return Value

array

An array of dependencies grouped by type (config, content, module, theme). For example: @code array( 'config' => array('user.role.anonymous', 'user.role.authenticated'), 'content' => array('node:article:f0a189e6-55fb-47fb-8005-5bef81c44d6d'), 'module' => array('node', 'user'), 'theme' => array('seven'), ); @endcode

See also

ConfigDependencyManager
EntityInterface::getConfigDependencyName

bool applyEffect(ImageInterface $image)

Applies an image effect to the image object.

Parameters

ImageInterface $image

An image file object.

Return Value

bool

TRUE on success. FALSE if unable to perform the image effect on the image.

transformDimensions(array $dimensions, string $uri)

Determines the dimensions of the styled image.

Parameters

array $dimensions

Dimensions to be modified - an array with the following keys:

  • width: the width in pixels, or NULL if unknown
  • height: the height in pixels, or NULL if unknown When either of the dimensions are NULL, the corresponding HTML attribute will be omitted when an image style using this image effect is used.
string $uri

Original image file URI. It is passed in to allow an effect to optionally use this information to retrieve additional image metadata to determine dimensions of the styled image. ImageEffectInterface::transformDimensions key objective is to calculate styled image dimensions without performing actual image operations, so be aware that performing IO on the URI may lead to decrease in performance.

string getDerivativeExtension(string $extension)

Returns the extension of the derivative after applying this image effect.

Parameters

string $extension

The file extension the derivative has before applying.

Return Value

string

The file extension after applying.

array getSummary()

Returns a render array summarizing the configuration of the image effect.

Return Value

array

A render array.

string label()

Returns the image effect label.

Return Value

string

The image effect label.

string getUuid()

Returns the unique ID representing the image effect.

Return Value

string

The image effect ID.

int|string getWeight()

Returns the weight of the image effect.

Return Value

int|string

Either the integer weight of the image effect, or an empty string.

$this setWeight(int $weight)

Sets the weight for this image effect.

Parameters

int $weight

The weight for this image effect.

Return Value

$this