Ejemplo n.º 1
0
 /**
  * Get the crop type correspond to current image style.
  *
  * @param \Drupal\image\Entity\ImageStyle $image_style
  *   The properties of the crop applied to the original image (dimensions).
  *
  * @return string $crop_type
  *   The name of Crop type.
  */
 public function getCropType(ImageStyle $image_style)
 {
     // Confirm that all effects on the image style have settings that match
     // what was saved.
     $uuids = array();
     /** @var  \Drupal\image\ImageEffectInterface $effect */
     foreach ($image_style->getEffects() as $uuid => $effect) {
         // Store the uuid for later use.
         $uuids[$effect->getPluginId()] = $uuid;
     }
     if (isset($uuids['image_widget_crop_crop'])) {
         $crop_type = $image_style->getEffect($uuids['image_widget_crop_crop'])->getConfiguration()['data']['crop_type'];
     } else {
         $crop_type = FALSE;
     }
     return $crop_type;
 }