-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement the image resize handler #5167
Comments
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 #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. |
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 ResizeFirst off, not only image requires resizing, there are few candidates that might use it:
DiscussionHandlers (must-have)
Based on the trends we should start with multiple resize handlers. There are a few pros for that:
The main issue is that it clutters the UI once the resized entity gets hovered/focused. Handlers positionOften times we're using captioned image. In that case it sounds only fair to bound handlers to the wrapper. Aspect ratioShould 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. LimitersOne might desire an option to constrain min and max size of resized object. AccessibilityAny feature of the editor should be accessible, this includes resizing too. As an example for shapes (this does not include image) MS Word support 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 FeaturesSince 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:
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. APIAn 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. SummaryIMHO 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 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! IntroductionThe 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 neededThere are couple of questions that we'd like to ask community:
Naturally if you'd like to share any thought beyond that, feel free to do so! TimingWe also decided to push back the release by one week so we have more time to discuss it. |
Great job, @mlewand! Resizing works great 👏
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 However:
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 |
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. |
Also, it would be nice if the demo provided upload adapter -- I wanted to check how it works with biiig images. |
Yup, this is a followup. Basically, we need a UI with an input for width so the feature is accessible and we can add more options, such as resetting the size. |
BTW, to people who reacted with 👍 to this comment – does that mean that you agree that the feature should use percentages? And if yes, do you think you might also need pixels in some applications (so we should support both options)? We'd be grateful for feedback on this because for us percentage values are the right direction because of content quality (its portability), but we know that there are many use cases in which CKEditor 5 is used, so we don't want to skip something unintentionally. |
@Reinmar the use case I had in mind was a page builder widget that could be rather narrow, but also rather wide, and dependent on viewport size. For all of those reasons, a Being that the initial implementation was in My suggestion is to have a way to do both - be it a config option or some other mechanism. |
@Reinmar supporting percentage will be good for device compatibility. And some might prefer pixels for precision having both will be good if possible. |
Thanks for initial feedback @chipcullen @sashi-yadav, appreciate it. In case plugin supports both pixels and percentages sizes, how would you expect it to be set up? Is it enough to allow developer to decide that on a per-editor basis (via config) or should it be something that can be changed during runtime? |
Maybe, there could be an input near the alignment options for the image with a toggle to switch between px and %. You can enter a value in the input and default would be %. If you resize by handles, it would set the width in whatever you toggled it to be in the toolbar (px or %) and also the value of your by-hand resize would show in the input (it is bidirectional). Maybe be able to change the default in the general config. |
☝️ and then removing everything from the input would reset the image. |
Just to give some feedback and ideas: About using percent scale, I think there should be a way to set min/max, as the image could be small and get really ugly in big screens. But don't know how this would be done. An idea about using % or px, when resizing from the drag points, use absolute, and if you want %, use the input as @totorean posted in the image. |
@scofalik @dkrahn @Reinmar I edited my comment ☝️to be more clear (sorry). What I suggested was to put the power of decision between px and % in the hands of the end user of the editor, not the developer that includes it in his site. The developer should just set a default in the config. Dunno if this is even possible :) |
A use case: They know best if they want px or %. Also, users understanding px better than % is a recurring argument, but if the input data is bidirectional, they can resize by handles, then go to the input in toolbar and see it is actually 23.7 % and set it to 24% or switch to px and see it's 203px...you get my point. |
First of all, thank you for the amazing work. |
@totorean I understood your comment, I just used your picture as a reference the input. To be clear this is my personal opinion I think that, IF POSSIBLE, @totorean idea is perfect.
This way if the developer decides that in his context, only px is valid, he can set available units to [px] and that's it. |
Feature: Introduced image widget resizer. Closes #241.
Feature: Introduced image widget resizer. See ckeditor/ckeditor5-image#241.
The base image resize has just landed on master 🎉 There have been some last minute changes needed when we started working on support for percentage values. It turned out that we needed to move the width style to Still, the thing that the user is resizing is the image. That's where the handles are displayed. And this creates some nasty cases. There's even more if we consider centered images, In other words, this seemingly simple feature has a tone of complexity inside :) Therefore, we're really happy that it made to the master and is on the straight road to the upcoming release. It will use percentage values by default but it supports px values too. That said, this is for sure the first step. We need some sort of input for the size values. Perhaps also some buttons for predefined widths. We'll be still processing your feedback from this ticket, but you feel free to open new tickets for specific extensions that you'd like to see. Thanks everyone for feedback and ideas. And @mlewand for a lot of hard work that he's put into this feature 👏 |
Hello, I and my colleague just released a plugin that allows you to edit the size of an image using width and height input, as well as providing an aspect ratio lock tool that makes it easy to scale without distorting the image. |
@adrianmihaila Give a thumbs up in #5198 if you want this to be a core feature 😀 |
@vineetsingh065 We're not maintaining any CKE5 Django integration, so you'd need to ask this the package maintainer. That being said, even if such integration doesn't support it, CKE5 is a plain JavaScript integration so you can make your own build using our online builder and for sure there's a way to include a js library in Django. |
Drupal is considering changing the default to |
Lots come down to a common practice for responsive images to follow: |
Hey @joelpittet, thanks for reaching out! I already answered on the Drupal issue, cross-posting some information here for the reference. We chose `%`, as a lot of people may not know the exact size of the container in which the content will be used. Often, content is used in multiple destinations at once. With pixels, one gets far less flexibility with how the content will be used in the future. As for the responsive option for the image, let us discuss it internally, and I will get back to you as soon as possible. |
@Witoso The |
The functionality of the enhanced image plugin in v4 is missing in v5.
A follow-up of #1330.
If you'd like to see this feature implemented, add 👍 to this post.
The text was updated successfully, but these errors were encountered: