Implement the image resize handler
The functionality of the enhanced image plugin in v4 is missing in v5.

A follow-up of https://github.com/ckeditor/ckeditor5/issues/1330.
If you'd like to see this feature implemented, add π to this post.
i'm very excepted to see this feature can be implemented ! thank you again ! Ckeditor is the best editor !
Thank you guys for the awesome editor. Any news on this item?
@programad It's in our backlog ATM, which means it's among our top priorities. But there are so many of features like this one I cannot tell you the exact ETA.
The feature has been requested in https://github.com/ckeditor/ckeditor5/issues/1401.
Thanks for the awesome work on CKEditor 5. This feature is essential to any CMS that supports image uploads.
I am planning on integrating it in our company and getting the license. But, the image resize is a very important feature for us to use this editor. Any ideas, if this feature has a chance to make to production.
As you might see we started working on this in this iteration. Though the date is not written in the stone just yet, we currently plan to release this iteration somewhere between 4-6th of June.
That being said, the feature will land in the code repository earlier than that. So if you can't wait to play with image resizing, be sure to subscribe this issue so that you're notified when the feature is available for the preview.
I did some research on that matter. Below are the findings.
Image Resize
First off, not only image requires resizing, there are few candidates that might use it:
- image
- media embed
- table
Discussion
Handlers (must-have)
- multiple resize handlers
- Google docs

- Firefox/IE native contenteditable implementation
- MS Word

- TinyMCE

- Froala

- Google docs
- single handler
- CKE4:

- Prose mirror 3rd party contrib:

- Redactor

- CKE4:
Based on the trends we should start with multiple resize handlers. There are a few pros for that:
- people are more familiar with it,
- we don't have to worry about bidi,
- aspect ratio issue (see "Aspect ratio" section) is solved
The main issue is that it clutters the UI once the resized entity gets hovered/focused.
Handlers position
Often times we're using captioned image. In that case it sounds only fair to bound handlers to the wrapper.
Aspect ratio
Should aspect ratio be locked? Should interface allow to lock unlock aspect ratio? Or maybe should it only be doable with keyboard modifier, e.g. holding a shift/alt or not.
Having multiple resize handlers, we can skip the feature and force corner handlers to keep the aspect ratio, while others will resize only along a single axis.
Limiters
One might desire an option to constrain min and max size of resized object.
Accessibility
Any feature of the editor should be accessible, this includes resizing too.
As an example for shapes (this does not include image) MS Word support shift+arrow. It supports alt+arrow for rotating images.
Accessibly doesn't necessairly needs be implemented as handling resizing using arrow. If we'd have some sort of accessible dialog that would allow for setting the size, that would be fine too.
Widget Features
Since this particular feature will be reused over other widgets it has to be implemented with a reusable API. We can think of it as a widget feature that should not be limited to images only.
There are several candidates like that:
- resize
- drag and drop
- upload
- overlay
So it would make sense to create a common API called widget features, that would serve as a framework for such drop-in self-contained feature implementations.
API
An example API might look something like that:
import { toWidget } from '@ckeditor/ckeditor5-widget/src/utils';
import { ResizeFeature } from '@ckeditor/ckeditor5-widget-feature-resize/src/resize';
// Simplest, hardcoded usage:
// (β¦)
return toWidget( viewElement, writer, {
label: labelCreator
features: [
ResizeFeature(),
DragAndDropFeature()
]
} );
// More realistic, configurable usage:
// (β¦)
let features = [];
if ( config.image.resize !== false ) {
features.push( ResizeFeature( config.image.resize ) );
}
if ( config.image.dragAndDrop ) {
features.push( DragAndDropFeature( config.image.dragAndDrop ) );
}
return toWidget( viewElement, writer, {
label: labelCreator,
features: features
} );
Note this is just a concept, I haven't yet verified it with any PoC.
Summary
IMHO our implementation should feature multiple resizers. It gives more functionality, we also don't have to worry about aspect ratio and bidirectional lang handling at a cost of slightly cluttered UI.
As for API I need to prepare PoC first to figure out if it plays the way I expect it to do. There's one thing that I'm worried about, where I'd need static listeners that should be initialized despite a widget was created or not (e.g. upload widget feature, that would listens for drops over the editable containing a certain mime type).
@mlewand Hey. when will be this on live on master branch? I was not able to find this module @ckeditor/ckeditor5-widget-feature-resize/src/resize
can you let me know how i can install/use this module in ckeditor-5
@saravana34 we're still in the design phase. We aim to ship it within current iteration. Subscribe the issue and you'll get notified once the pre-release is ready π
I hope this can be done soon , it is a necessary feature
This is feature is a really good one, so please make add it in thank you, guys.
this is feature is good, i need feature !!!
Almost a year in the pastοΌany process on this?
@mlewand looking forward for the fix.. please keep us updated
Any update or walk through?
@swebsas Iteration 26 roadmap includes it and its due on August 19th. it's coming, finally :)
π Preview available π
Hey all! We've been silent for last couple of weeks as we've been working hard to prepare a preview of our image resize feature and I'm pleased to share it with you.
You can find it on https://ckeditor5.github.io/misc/image-resize/ - please give it a try!
Introduction
The image resize handlers will be shown once you focus the image (click it or navigate there using the keyboard).
There are couple of details, like inconsistent cursor or resizers not disappearing when editor is blurred - which we're aware and will be ironed out during next couple of days.
Feedback needed
There are couple of questions that we'd like to ask community:
- The image size is saved as inline
widthstyle applied toimgelement in pixels. We're wondering whether there are use cases when you'd like to use percents rather than pixels? If so please, let us know the use cases. - By default CKEditor's 5 side images have max-width limited to 50%. It doesn't feel right to be limited to that when using the resize feature, so we decided to add a class
ck_resizedto thefigureonce image is resized - in which case it doesn't have this limitation. It also gives an easy option to customize it in case developer decides that such images should be in fact limited. We don't see any downsides here, but feel free to share your opinion.
Naturally if you'd like to share any thought beyond that, feel free to do so!
Timing
We also decided to push back the release by one week so we have more time to discuss it.
Great job, @mlewand! Resizing works great π
The image size is saved as inline width style applied to img element in pixels. We're wondering whether there are use cases when you'd like to use percents rather than pixels? If so please, let us know the use cases.
All the RTEs use pixels, but I think this is wrong. This makes the images completely unresponsive. How do you know how wide the content that you're displaying will be? The column with the text may have 900px on desktop, but 500px on mobile.
Therefore, I think we should use percentage values. This will ensure that images scale well with the content. E.g. we use percentage values in the default image styles (side image has max-width 50%).
However:
- Should the feature be using percentage values by default?
- Should we support both modes? Or can we support only percentage values?
- How will percentage values work in tables?
By default CKEditor's 5 side images have max-width limited to 50%. It doesn't feel right to be limited to that when using the resize feature, so we decided to add a class ck_resized to the figure once image is resized - in which case it doesn't have this limitation. It also gives an easy option to customize it in case developer decides that such images should be in fact limited. We don't see any downsides here, but feel free to share your opinion.
I generally like this idea. It makes the image styles and image resizing features cooperate well. You first make the image "aside" (or "left/right/center aligned", depending on your settings) and the image momentarily changes its width to the hardcoded 50%. But thanks to the image resize feature, you can override that value. Once you start resizing, the image's style should be overriden and for that we need the new class.
By using the class we give the developers full control over how they are going to handle that. E.g. one may decide to set min/max-widths for resized images too.
The only minor detail is that this class should rather look like ck-image__resized, AFAIK.
I am missing a way to bring back the image to the original size. I could see that as a button in image toolbar or even like double-clicking on a resize handler.