You are here

protected function DemoFile::applyCrops in Open Social 8.4

Same name and namespace in other branches
  1. 8.9 modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
  2. 8 modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
  3. 8.2 modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
  4. 8.3 modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
  5. 8.5 modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
  6. 8.6 modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
  7. 8.7 modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
  8. 8.8 modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
  9. 10.3.x modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
  10. 10.0.x modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
  11. 10.1.x modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
  12. 10.2.x modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()

Crops the images.

Parameters

array $item: The array with items.

\Drupal\file\FileInterface $entity: The FileInterface entity.

1 call to DemoFile::applyCrops()
DemoFile::createContent in modules/custom/social_demo/src/DemoFile.php
Creates content.

File

modules/custom/social_demo/src/DemoFile.php, line 130

Class

DemoFile
Class DemoFile.

Namespace

Drupal\social_demo

Code

protected function applyCrops(array $item, FileInterface $entity) {

  // Add coordinates for cropping images.
  foreach ($item['crops'] as $crop_name => $data) {
    $crop_type = $this->entityTypeManager
      ->getStorage('crop_type')
      ->load($crop_name);
    if (!empty($crop_type) && $crop_type instanceof CropType) {
      $this->imageWidgetCropManager
        ->applyCrop($data, [
        'file-uri' => $item['uri'],
        'file-id' => $entity
          ->id(),
      ], $crop_type);
    }
  }
}