php – Summernote – Adding images with file-size limit-ThrowExceptions

Exception or error:

I’ve been googling everywhere to find a way to prevent any images bigger than 500kb but haven’t found a single solution. The reason why I’m trying to limit the file size of images is for mobile users using limited data plans.

I ended up believing that it’s impossible because summernote saves images as text something like this…..


and generate back as an image when needed.

Do I still need to limit the file size even if I store them as text in DB?

If I have to, is there an api for this?

How to solve:

If i understand correctly you use this please check the maximumFileSize: ‘Maximum file size’, parameter in the image option. In there you can set the limit you want.


You can limit the picture size in summernote plugin by adding these options:

    // your options... and
    maximumImageFileSize: 500*1024, // 500 KB
        onImageUploadError: function(msg){
           console.log(msg + ' (1 MB)');


Check this link:

maximumImageFileSize: 1048576

Leave a Reply

Your email address will not be published. Required fields are marked *