Is there a way to control/limit the size of an image file?

Hello,

my question is very simple: is there a way to control/limit the size of an image file pasted or uploaded to a RichtextEditor in order to avoid the user to upload huge images?


3 Replies

VJ Vinitha Jeyakumar Syncfusion Team September 19, 2022 09:58 AM UTC

Hi QED,


Your requirement to control the image size can be achieved by using the maxHeight and maxWidth property of the insertImageSettings in Rich Text Editor. please check code and sample below,

Code snippet:
let defaultRTERichTextEditor = new RichTextEditor({
  insertImageSettings: {
    maxHeight: '200px',
    maxWidth: '200px',
  },
});
defaultRTE.appendTo('#defaultRTE');





Regards,
Vinitha


QE QED September 19, 2022 10:31 AM UTC

Hi Vinitha,

thank you for your reply, but (my fault) I meant the FILESIZE of the image! I would like to limit the size of the file a user can upload or paste to the RTE control in order to avoid the creation of documents impossible to load/view or edit. Any hi

Sorry for the misunderstanding.

Domenico



VJ Vinitha Jeyakumar Syncfusion Team September 20, 2022 06:21 AM UTC

Hi QED,


By using the Rich text editor’s imageUploading event, you can get the image size before uploading and restrict the image to upload, when the given image size is greater than the allowed size.

Documentationhttps://ej2.syncfusion.com/documentation/rich-text-editor/how-to/file-size/


Regards,
Vinitha

Loader.
Up arrow icon