0

I'm working with summernote, the problem we currently are facing is, how to limit the size of a file when a user pastes it. We already disabled the tool, so no upload through that.

The only way that images can be added is through paste (ctrl+v). We want to allow only images under 2 MB to be added.

$('textarea.summernote').summernote({
      toolbar:[],
      height: h,
      maximumImageFileSize: 2097152,
      callbacks: {
        onPaste: function(e) {
          //Do Something
        }
      }

});

Even though we specified maximumImageFileSize, it's still possible to paste images above the 2 MB limit, or to resize it.

Wyck
  • 10,311
  • 6
  • 39
  • 60
Zocatelli
  • 188
  • 2
  • 11

1 Answers1

0

You need to put a bit more effort into this. Actually, client side upload size restrictions used to be completely impossible. Today, you can do it with a bit of JavaScript. See this post on SO.

Holli
  • 5,072
  • 10
  • 27
  • So, it's not a upload, and it's a paste on summernote, I tried that, and others JS methods, but to no avail. – Zocatelli Aug 30 '19 at 18:22