Ckeditor5: Base64UploadAdapter: Limit image size

Created on 24 Oct 2019  路  3Comments  路  Source: ckeditor/ckeditor5

馃摑 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.

feature

Most helpful comment

馃摑 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

All 3 comments

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:

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

Was this page helpful?
0 / 5 - 0 ratings