Problem/Motivation
In #3280279: Allow sites to programmatically opt in to accept more image type uploads in CKEditor 5: TIFF, SVG… we added hook_ckeditor5_image_controller_extensions_alter() to allow other modules to modify the list of allowed extensions for CKEditor5's image upload plugin.
WebP is officially adopted as an image type by Drupal core, so we need to add CKEditor5 support for it. See #3280279-26: Allow sites to programmatically opt in to accept more image type uploads in CKEditor 5: TIFF, SVG… for more information.
Proposed resolution
Update \Drupal\ckeditor5\Controller\CKEditor5ImageController::upload() to add webp as a valid file name extension.
Update core/modules/ckeditor5/ckeditor5.ckeditor5.yml -> ckeditor5_imageUpload -> ckeditor5 -> config -> image -> upload -> types to add webp as a valid IANA file type.
Remaining tasks
- Commit #3280279: Allow sites to programmatically opt in to accept more image type uploads in CKEditor 5: TIFF, SVG…
- Write a patch
- Review and feedback
- RTBC and feedback
- Commit
User interface changes
It is now possible to upload WebP images to CKEditor5 by dragging-and-dropping or using the image upload button.
API changes
None.
Data model changes
None.
Release notes snippet
Added CKEditor5 support for WebP images.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3386605-9-add-ckeditor5-support-for-webp.patch | 1.75 KB | mreda |
| #7 | 3386605-1.patch | 1.36 KB | ankondrat4 |
Issue fork drupal-3386605
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3386605-pp-1-add-ckeditor5
changes, plain diff MR !5734
Comments
Comment #4
g-brodieiEven though this issue is postponed, I ran into this request earlier today and needed a patch to allow ckeditor5 to work with uploading webp files.
I'm leaving this MR for the future when other dependent issues are resolved, or others who may need a quick fix to make use of this as a patch.
Tested with 10.1.x
Hope this helps, Thanks!
Comment #5
dave_______1 commentedThe above seems to work for webp and Drupal 10.1 without the patch linked but after an update to 10.2 it obviously reverted so had to be re-added.
Would be great to have webp, svg and avif in core fields and CKEditor.
Comment #6
wim leersComment #7
ankondrat4 commentedHello.
Added patch for Drupal core 10.2.6
Comment #8
nelo_drup commentedAdd comatibility with Drupal 10.3.1
Comment #9
mreda commentedAdding a patch for Drupal 10.3
Comment #10
transmitter commentedI've just tried to apply the patch #9 in D11 but it didn't work:
Comment #13
quietone commentedThere is no indication here why this is postponed, so I am changing this to active.
Comment #14
quietone commentedComment #15
lionsea commentedI don't know this is an issue or not, but full WebP support including CKeditor's image upload button is always my concern.
I had no clue to activate full WebP support for CKeditor's image upload button, so only my solution is overwriting the core source code of ckeditor5.ckeditor5.yml. That works but I have to overwrite whenever update my core.
people who want to use WebP at Drupal11 search information at internet and would just found that Drupal11 fully supports WebP but they would never find how to activate it. So I suggest that Drupal core supports WebP by default or clearly document how to use WebP in the official documentation.