Problem/Motivation
In the text format settings in "CKEditor 5 plugin settings" section for "Image" plugin, "Maximum dimensions" setting is not applied to the uploaded image.
Steps to reproduce
1) Create text format with Text editor = CKEditor 5
2) Add "Image" button to Active toolbar.
3) In "CKEditor 5 plugin settings" section for "Image" plugin check "Enable image uploads"
4) Set the value of "Maximum dimensions" settings
5) In node add or edit form, select the created text formatter for Body field and use "Image" button to upload an image with higher resolution than you specified in "Maximum dimensions" settings
Proposed resolution
In \Drupal\ckeditor5\Controller\CKEditor5ImageController::upload() method, $file->setFileUri($file_uri) method is called to set the new destination and then file_validate()(which includes file_validate_image_resolution() call) is called before $this->fileSystem->move()
Solution: Call file_validate() function for a temporary file.
Please review patch.
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3373793-4.patch | 3.86 KB | sakthi_dev |
| #3 | 3373793-nr-bot.txt | 1.57 KB | needs-review-queue-bot |
| #2 | Screenshot 2023-07-11 at 1.48.04 PM.png | 107.62 KB | keshavv |
| #2 | Screenshot 2023-07-11 at 1.43.25 PM.png | 112.04 KB | keshavv |
| #2 | Screenshot 2023-07-11 at 1.43.51 PM.png | 100.5 KB | keshavv |
Comments
Comment #2
keshavv commentedI confirmed that the issue is there.
I have tested the patch and noticed that After applying the patch the image will be converted to that dimension instead of validation.
I think it will need more eyes.
Before patch.


After applying the patch.

Comment #3
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #4
sakthi_dev commentedPlease review.
Comment #5
smustgrave commentedComment #6
larowlanI think this is the same problem as #3372385: CKEditor file upload sets file URI prior to validation, causing validators to be unable to find the file.
Let's work together over there