protected function DemoFile::applyCrops in Open Social 8
Same name and namespace in other branches
- 8.9 modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
- 8.2 modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
- 8.3 modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
- 8.4 modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
- 8.5 modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
- 8.6 modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
- 8.7 modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
- 8.8 modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
- 10.3.x modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
- 10.0.x modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
- 10.1.x modules/custom/social_demo/src/DemoFile.php \Drupal\social_demo\DemoFile::applyCrops()
- 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_demoCode
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);
}
}
}