ckeditor5
ckeditor5 copied to clipboard
Base64UploadAdapter: Limit image size
📝 Limit image size (Feature request)
Hi everyone! I use base64 adapter for images: https://ckeditor.com/docs/ckeditor5/latest/features/image-upload/base64-upload-adapter.html
I choose a big picture and it converted to base64 string:
And it is very very very big long base64 string :) It would be useful to add some size limits for image, set max width or max height in configuration
I remember that browsers don't like such large strings and it may occur an error or bad response on submit
If you'd like to see this feature implemented, add a 👍 reaction to this post.
That's right. Putting big pictures as base64 encoded images definitely impacts the performance.
📝 Limit image size (Feature request)
Hi everyone! I use base64 adapter for images: https://ckeditor.com/docs/ckeditor5/latest/features/image-upload/base64-upload-adapter.html
I choose a big picture and it converted to base64 string:
And it is very very very big long base64 string :) It would be useful to add some size limits for image, set max width or max height in configuration
I remember that browsers don't like such large strings and it may occur an error or bad response on submit
If you'd like to see this feature implemented, add a 👍 reaction to this post.
you can use this https://github.com/cristianizzo/ckeditor5-build-classic/blob/stable/src/modules/base64uploadAdapter.js#L84
it resizes the image to 1.5mb, you can change here https://github.com/cristianizzo/ckeditor5-build-classic/blob/stable/src/modules/imageCompressor.js#L6
I am using document verzion of ck and also using base 64 for image upload. My editor is getting crash if I upload a large image. So for that, I was thinking to restrict the user to upload the image of large size just image below 1mb will be allowed to upload in the editor.
So for that, I have added the "imageCompressor.js" as you mention above but seems it's not working or I may have not to implement it correctely. I have set up the built form online of the document version of CKeditor 5.
@eleave @cristianizzo
This issue really needs to be solved. We need a way to restrict insert/paste of images above a specified byte size and/or image dimensions. The files referenced by @cristianizzo didn't work for me.
Is there any update on this in terms of when / if it is going to be considered?
EDIT: I wrote a plugin to handle this:
https://gist.github.com/letdowncrush/0692ad207c718f10a0a468aee8a29074
📝 Limit image size (Feature request)
Hi everyone! I use base64 adapter for images: https://ckeditor.com/docs/ckeditor5/latest/features/image-upload/base64-upload-adapter.html I choose a big picture and it converted to base64 string:
And it is very very very big long base64 string :) It would be useful to add some size limits for image, set max width or max height in configuration I remember that browsers don't like such large strings and it may occur an error or bad response on submit If you'd like to see this feature implemented, add a 👍 reaction to this post.
you can use this https://github.com/cristianizzo/ckeditor5-build-classic/blob/stable/src/modules/base64uploadAdapter.js#L84
it resizes the image to 1.5mb, you can change here https://github.com/cristianizzo/ckeditor5-build-classic/blob/stable/src/modules/imageCompressor.js#L6
I would also recommend set initialQuality: 0.9
or something like, otherwise file size (mb) will not be so much smaller
I can see this is a trending issue but I'm a bit confused on why.
- Why do you use base64 adapter at all? What are the use cases for it?
- This approach has its natural limitations and is non-optimal. Scaling images down might be an option, of course, but it's a bit like treating symptoms rather than the root cause. I guess this gets us back to the first question a bit, but I'm sure you know that. Then why trying to stick to the base64 adapter? Why not any other adapter?
- Are there any other approaches than resizing that you'd consider solutions to this issue?
i am facing the same issue is there any way that my images does'nt get change in base 64? i want my image url to be set there
Hi, is there still no solution to this? I find myself in the same problem.