public function ImageWidgetCropManager::applyCrop in Image Widget Crop 8
Same name and namespace in other branches
- 8.2 src/ImageWidgetCropManager.php \Drupal\image_widget_crop\ImageWidgetCropManager::applyCrop()
Create new crop entity with user properties.
Parameters
array $properties: All properties returned by the crop plugin (js), and the size of thumbnail image.
array|mixed $field_value: An array of values for the contained properties of image_crop widget.
CropType $crop_type: The entity CropType.
2 calls to ImageWidgetCropManager::applyCrop()
- ImageWidgetCropManager::buildCropToEntity in src/
ImageWidgetCropManager.php - Fetch all fields FileField and use "image_crop" element on an entity.
- ImageWidgetCropManager::buildCropToForm in src/
ImageWidgetCropManager.php - Fetch all form elements using image_crop element.
File
- src/
ImageWidgetCropManager.php, line 80
Class
- ImageWidgetCropManager
- ImageWidgetCropManager calculation class.
Namespace
Drupal\image_widget_cropCode
public function applyCrop(array $properties, $field_value, CropType $crop_type) {
// Get Original sizes and position of crop zone.
$crop_properties = $this
->getCropOriginalDimension($field_value, $properties);
// Get all imagesStyle used this crop_type.
$image_styles = $this
->getImageStylesByCrop($crop_type
->id());
$this
->saveCrop($crop_properties, $field_value, $image_styles, $crop_type, FALSE);
}