ckeditor5 icon indicating copy to clipboard operation
ckeditor5 copied to clipboard

Base64UploadAdapter: Limit image size

Open eleave opened this issue 4 years ago • 6 comments

📝 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:

limit

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.

eleave avatar Oct 24 '19 15:10 eleave

That's right. Putting big pictures as base64 encoded images definitely impacts the performance.

mlewand avatar Oct 25 '19 08:10 mlewand

📝 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:

limit

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

cristianizzo avatar Oct 28 '19 18:10 cristianizzo

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

ankitkumarsuthar avatar Oct 30 '20 05:10 ankitkumarsuthar

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.

argentini avatar Mar 15 '21 19:03 argentini

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

letdowncrush avatar Jun 01 '21 11:06 letdowncrush

📝 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: limit 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

talski avatar Jul 07 '21 21:07 talski

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?

Reinmar avatar Aug 02 '23 09:08 Reinmar

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

vishalsolanki-v avatar Oct 12 '23 06:10 vishalsolanki-v

Hi, is there still no solution to this? I find myself in the same problem.

alonsofc avatar Feb 14 '24 20:02 alonsofc