CKEditor5 image upload maximum dimensions don't work

Created on 11 July 2023, 12 months ago

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

🐛 Bug report
Status

Closed: duplicate

Version

10.1

Component
CKEditor 5 

Last updated 43 minutes ago

Created by

🇺🇦Ukraine alextars

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024