Summary
It is now possible to add CKEditor 5 image upload support for additional image types such as tiff, webp and avif. This is done programmatically in a module because certain file types have security risks (e.g. SVG).
Usage
function my_module_ckeditor5_plugin_info_alter(array &$plugin_definitions): void {
// @see https://www.iana.org/assignments/media-types/media-types.xhtml#image
// @see https://ckeditor.com/docs/ckeditor5/latest/api/module_image_imageconfig-ImageUploadConfig.html#member-types
$image_upload_plugin_definition = $plugin_definitions['ckeditor5_imageUpload']->toArray();
$image_upload_plugin_definition['ckeditor5']['config']['image']['upload']['types'][] = 'webp';
$plugin_definitions['ckeditor5_imageUpload'] = new CKEditor5PluginDefinition($image_upload_plugin_definition);
}
Additional Changes
The method signature for \Drupal\ckeditor5\Controller\CKEditor5ImageController::__construct() has changed from:
__construct(FileSystemInterface $file_system, AccountInterface $current_user, MimeTypeGuesserInterface $mime_type_guesser, LockBackendInterface $lock, EventDispatcherInterface $event_dispatcher, FileValidatorInterface $file_validator = NULL)
to:
__construct(FileSystemInterface $fileSystem, AccountInterface $currentUser, MimeTypeGuesserInterface $mimeTypeGuesser, LockBackendInterface $lock, EventDispatcherInterface $eventDispatcher, FileValidatorInterface $file_validator = NULL, ?CKEditor5PluginManagerInterface $pluginManager = NULL)