diff --git a/src/Plugin/ImageEffect/CropEffect.php b/src/Plugin/ImageEffect/CropEffect.php index 5f41e6b..1cbaa2b 100644 --- a/src/Plugin/ImageEffect/CropEffect.php +++ b/src/Plugin/ImageEffect/CropEffect.php @@ -103,6 +103,26 @@ class CropEffect extends ConfigurableImageEffectBase implements ContainerFactory return FALSE; } } + elseif (\Drupal::moduleHandler()->moduleExists('automated_crop')) { + $crop_type = $this->typeStorage->load($this->configuration['crop_type']); + $hard_limit = $crop_type->getHardLimit(); + $configuration = [ + 'uuid' => NULL, + 'id' => 'automated_crop', + 'weight' => 0, + 'data' => [ + 'width' => NULL, + 'height' => NULL, + 'min_width' => $hard_limit['width'], + 'min_height' => $hard_limit['height'], + 'max_width' => NULL, + 'max_height' => NULL, + 'aspect_ratio' => $crop_type->getAspectRatio(), + ], + ]; + $automated_crop_effect = \Drupal::service('plugin.manager.image.effect')->createInstance($configuration['id'], $configuration); + return $automated_crop_effect->applyEffect($image); + } return TRUE; }