You are here

protected static function Crop::getEffectsFromImageStyleId in Crop API 8.2

Returns the effects for an image style.

Parameters

string $image_style_id: The image style ID.

Return value

array[] A list of effects, keyed by plugin ID, each effect has a uuid, provider and in case of crop_crop, the type key.

1 call to Crop::getEffectsFromImageStyleId()
Crop::getCropFromImageStyleId in src/Entity/Crop.php
Retrieve crop from given image style.

File

src/Entity/Crop.php, line 194

Class

Crop
Defines the crop entity class.

Namespace

Drupal\crop\Entity

Code

protected static function getEffectsFromImageStyleId($image_style_id) {
  if (!isset(static::$effectsByImageStyle[$image_style_id])) {
    $image_style = ImageStyle::load($image_style_id);
    if ($image_style === NULL) {
      return [];
    }
    $effects = [];
    foreach ($image_style
      ->getEffects() as $uuid => $effect) {

      /** @var \Drupal\image\ImageEffectInterface $effect */

      // Store the effects parameters for later use.
      $effects[$effect
        ->getPluginId()] = [
        'uuid' => $uuid,
        'provider' => $effect
          ->getPluginDefinition()['provider'],
      ];
      if ($effect
        ->getPluginId() === 'crop_crop') {
        $effects[$effect
          ->getPluginId()]['type'] = $effect
          ->getConfiguration()['data']['crop_type'];
      }
    }
    static::$effectsByImageStyle[$image_style_id] = $effects;
  }
  return static::$effectsByImageStyle[$image_style_id];
}