public static function ImageCropWidget::process in Image Widget Crop 8.2
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldWidget/ImageCropWidget.php \Drupal\image_widget_crop\Plugin\Field\FieldWidget\ImageCropWidget::process()
Form API callback: Processes a crop_image field element.
Expands the image_image type to include the alt and title fields.
This method is assigned as a #process callback in formElement() method.
Return value
array The elements with parents fields.
Overrides ImageWidget::process
File
- src/
Plugin/ Field/ FieldWidget/ ImageCropWidget.php, line 120
Class
- ImageCropWidget
- Plugin implementation of the 'image_widget_crop' widget.
Namespace
Drupal\image_widget_crop\Plugin\Field\FieldWidgetCode
public static function process($element, FormStateInterface $form_state, $form) {
if ($element['#files']) {
foreach ($element['#files'] as $file) {
$element['image_crop'] = [
'#type' => 'image_crop',
'#file' => $file,
'#crop_type_list' => $element['#crop_list'],
'#crop_preview_image_style' => $element['#crop_preview_image_style'],
'#show_default_crop' => $element['#show_default_crop'],
'#show_crop_area' => $element['#show_crop_area'],
'#warn_multiple_usages' => $element['#warn_multiple_usages'],
'#crop_types_required' => $element['#crop_types_required'],
];
}
}
return parent::process($element, $form_state, $form);
}