You are here

public function ImageWidgetCropManager::getEffectData in Image Widget Crop 8

Same name and namespace in other branches
  1. 8.2 src/ImageWidgetCropManager.php \Drupal\image_widget_crop\ImageWidgetCropManager::getEffectData()

Get one effect instead of ImageStyle.

Parameters

\Drupal\image\Entity\ImageStyle $image_style: The ImageStyle to get data.

string $data_type: The type of data needed in current ImageStyle.

Return value

mixed|null The effect data in current ImageStyle.

2 calls to ImageWidgetCropManager::getEffectData()
ImageWidgetCropManager::getAvailableCropImageStyle in src/ImageWidgetCropManager.php
Verify if ImageStyle is correctly configured.
ImageWidgetCropManager::getImageStylesByCrop in src/ImageWidgetCropManager.php
Get the imageStyle using this crop_type.

File

src/ImageWidgetCropManager.php, line 258

Class

ImageWidgetCropManager
ImageWidgetCropManager calculation class.

Namespace

Drupal\image_widget_crop

Code

public function getEffectData(ImageStyle $image_style, $data_type) {
  $data = NULL;

  /* @var  \Drupal\image\ImageEffectInterface $effect */
  foreach ($image_style
    ->getEffects() as $uuid => $effect) {
    $data_effect = $image_style
      ->getEffect($uuid)
      ->getConfiguration()['data'];
    if (isset($data_effect[$data_type])) {
      $data = $data_effect[$data_type];
    }
  }
  return $data;
}