public function WebformImageFile::prepare in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/WebformImageFile.php \Drupal\webform\Plugin\WebformElement\WebformImageFile::prepare()
Prepare an element to be rendered within a webform.
Parameters
array $element: An element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission. Webform submission is optional since it is not used by composite sub elements.
Overrides WebformManagedFileBase::prepare
See also
\Drupal\webform\Element\WebformCompositeBase::processWebformComposite
File
- src/
Plugin/ WebformElement/ WebformImageFile.php, line 43
Class
- WebformImageFile
- Provides a 'webform_image_file' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) {
parent::prepare($element, $webform_submission);
// Add upload resolution validation.
$max_resolution = $this
->getElementProperty($element, 'max_resolution');
$min_resolution = $this
->getElementProperty($element, 'min_resolution');
if ($max_resolution || $min_resolution) {
$element['#upload_validators']['file_validate_image_resolution'] = [
$max_resolution,
$min_resolution,
];
}
}