function CKEditor5ImageController::getImageUploadValidators
Gets the image upload validators.
1 call to CKEditor5ImageController::getImageUploadValidators()
- CKEditor5ImageController::upload in core/
modules/ ckeditor5/ src/ Controller/ CKEditor5ImageController.php  - Uploads and saves an image from a CKEditor 5 POST.
 
File
- 
              core/
modules/ ckeditor5/ src/ Controller/ CKEditor5ImageController.php, line 202  
Class
- CKEditor5ImageController
 - Returns response for CKEditor 5 Simple image upload adapter.
 
Namespace
Drupal\ckeditor5\ControllerCode
protected function getImageUploadValidators(array $settings) : array {
  $max_filesize = $settings['max_size'] ? Bytes::toNumber($settings['max_size']) : Environment::getUploadMaxSize();
  $max_dimensions = 0;
  if (!empty($settings['max_dimensions']['width']) || !empty($settings['max_dimensions']['height'])) {
    $max_dimensions = $settings['max_dimensions']['width'] . 'x' . $settings['max_dimensions']['height'];
  }
  $mimetypes = MimeTypes::getDefault();
  $imageUploadPlugin = $this->pluginManager
    ->getDefinition('ckeditor5_imageUpload')
    ->toArray();
  $allowed_extensions = [];
  foreach ($imageUploadPlugin['ckeditor5']['config']['image']['upload']['types'] as $mime_type) {
    $allowed_extensions = array_merge($allowed_extensions, $mimetypes->getExtensions('image/' . $mime_type));
  }
  return [
    'FileExtension' => [
      'extensions' => implode(' ', $allowed_extensions),
    ],
    'FileSizeLimit' => [
      'fileLimit' => $max_filesize,
    ],
    'FileImageDimensions' => [
      'maxDimensions' => $max_dimensions,
    ],
  ];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.