You are here

protected function AutomatedCropEffect::getAutomatedCrop in Automated Crop 8

Gets crop coordinates.

Parameters

\Drupal\Core\Image\ImageInterface $image: Image object.

Return value

\Drupal\automated_crop\AutomatedCropInterface|false Crop coordinates onto original image.

1 call to AutomatedCropEffect::getAutomatedCrop()
AutomatedCropEffect::applyEffect in src/Plugin/ImageEffect/AutomatedCropEffect.php
Applies an image effect to the image object.

File

src/Plugin/ImageEffect/AutomatedCropEffect.php, line 254

Class

AutomatedCropEffect
Provide an Automatic crop tools.

Namespace

Drupal\automated_crop\Plugin\ImageEffect

Code

protected function getAutomatedCrop(ImageInterface $image) {
  if (!isset($this->automatedCrop)) {
    $this->automatedCrop = FALSE;
    $crop_coordinates = $this->automatedCropManager
      ->createInstance($this->configuration['provider'], [
      'image' => $image,
      'width' => $this->configuration['width'],
      'height' => $this->configuration['height'],
      'min_width' => $this->configuration['min_width'],
      'min_height' => $this->configuration['min_height'],
      'max_width' => $this->configuration['max_width'],
      'max_height' => $this->configuration['max_height'],
      'aspect_ratio' => $this->configuration['aspect_ratio'],
    ]);
    if ($crop_coordinates) {
      $this->automatedCrop = $crop_coordinates;
    }
  }
  return $this->automatedCrop;
}