You are here

public function ImageWidgetCropManager::getAvailableCropImageStyle in Image Widget Crop 8

Verify if ImageStyle is correctly configured.

Parameters

array $styles: The list of available ImageStyle.

Return value

array<integer> The list of styles filtred.

File

src/ImageWidgetCropManager.php, line 393

Class

ImageWidgetCropManager
ImageWidgetCropManager calculation class.

Namespace

Drupal\image_widget_crop

Code

public function getAvailableCropImageStyle(array $styles) {
  $available_styles = [];
  foreach ($styles as $style_id => $style_label) {
    $style_loaded = $this->imageStyleStorage
      ->loadByProperties([
      'name' => $style_id,
    ]);

    /** @var \Drupal\image\Entity\ImageStyle $image_style */
    $image_style = $style_loaded[$style_id];
    $effect_data = $this
      ->getEffectData($image_style, 'width');
    if (!empty($effect_data)) {
      $available_styles[$style_id] = $style_label;
    }
  }
  return $available_styles;
}