You are here

public function ImageWidgetCropManager::getImageStylesByCrop in Image Widget Crop 8

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

Get the imageStyle using this crop_type.

Parameters

string $crop_type_name: The id of the current crop_type entity.

Return value

array All imageStyle used by this crop_type.

6 calls to ImageWidgetCropManager::getImageStylesByCrop()
ImageWidgetCropManager::applyCrop in src/ImageWidgetCropManager.php
Create new crop entity with user properties.
ImageWidgetCropManager::buildCropToEntity in src/ImageWidgetCropManager.php
Fetch all fields FileField and use "image_crop" element on an entity.
ImageWidgetCropManager::buildCropToForm in src/ImageWidgetCropManager.php
Fetch all form elements using image_crop element.
ImageWidgetCropManager::deleteCrop in src/ImageWidgetCropManager.php
Delete the crop when user delete it.
ImageWidgetCropManager::getAvailableCropType in src/ImageWidgetCropManager.php
Verify if the crop is used by a ImageStyle.

... See full list

File

src/ImageWidgetCropManager.php, line 280

Class

ImageWidgetCropManager
ImageWidgetCropManager calculation class.

Namespace

Drupal\image_widget_crop

Code

public function getImageStylesByCrop($crop_type_name) {
  $styles = [];
  $image_styles = $this->imageStyleStorage
    ->loadMultiple();

  /** @var \Drupal\image\Entity\ImageStyle $image_style */
  foreach ($image_styles as $image_style) {
    $image_style_data = $this
      ->getEffectData($image_style, 'crop_type');
    if (!empty($image_style_data) && $image_style_data == $crop_type_name) {
      $styles[] = $image_style;
    }
  }
  return $styles;
}