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

Comments

alextars created an issue. See original summary.

keshavv’s picture

I 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.
Before patch
Before patch

After applying the patch.
After patch

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new1.57 KB

The 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.

sakthi_dev’s picture

Status: Needs work » Needs review
StatusFileSize
new3.86 KB

Please review.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
larowlan’s picture

Status: Needs work » Closed (duplicate)
Issue tags: +Bug Smash Initiative