protected function CropEffect::getCrop in Crop API 8.2
Same name and namespace in other branches
- 8 src/Plugin/ImageEffect/CropEffect.php \Drupal\crop\Plugin\ImageEffect\CropEffect::getCrop()
Gets crop entity for the image.
Parameters
\Drupal\Core\Image\ImageInterface $image: Image object.
Return value
\Drupal\Core\Entity\EntityInterface|\Drupal\crop\CropInterface|false Crop entity or FALSE.
1 call to CropEffect::getCrop()
- CropEffect::applyEffect in src/
Plugin/ ImageEffect/ CropEffect.php - Applies an image effect to the image object.
File
- src/
Plugin/ ImageEffect/ CropEffect.php, line 216
Class
- CropEffect
- Crops an image resource.
Namespace
Drupal\crop\Plugin\ImageEffectCode
protected function getCrop(ImageInterface $image) {
if ($crop = Crop::findCrop($image
->getSource(), $this->configuration['crop_type'])) {
$this->crop = $crop;
}
if (!$this->crop && !empty($this->configuration['automatic_crop_provider'])) {
/** @var \Drupal\crop\Entity\CropType $crop_type */
$crop_type = $this->typeStorage
->load($this->configuration['crop_type']);
$automatic_crop_event = new AutomaticCrop($image, $crop_type, $this->configuration);
$this->eventDispatcher
->dispatch(Events::AUTOMATIC_CROP, $automatic_crop_event);
$this->crop = $automatic_crop_event
->getCrop();
}
return $this->crop;
}