Jonan Jonan - 3 months ago 144
Javascript Question

Disable image upload in Summernote

Is there any way to completely disable uploading of images in Summernote, but keep the image url input? The closest thing I found was the

disableDragAndDrop: true
option, but this doesn't remove the upload button from the image pop-up

Answer

There's probably a better way to accomplish what you're going for... but a very simple solution that comes to mind is to just add this to your stylesheets:

.note-group-select-from-files {
  display: none;
}

It works perfectly to leave just the image url input, and accomplishes what you're going for unless someone were to inspect element and discover that the upload element still exists with display none:

enter image description here


Edit : I took a look at the Summernote source code, and it looks like the above solution is actually a good way to go. There's currently no api to disable just the file upload button, let alone do so while leaving the img url input intact. You could always add it and open a pull request, of course.

https://github.com/summernote/summernote/blob/4b1bf144862a88899a464ddfab6bc0593a061fbc/src/js/bs3/module/ImageDialog.js#L24

  var body = '<div class="form-group note-group-select-from-files">' +
               '<label>' + lang.image.selectFromFiles + '</label>' +
               '<input class="note-image-input form-control" type="file" name="files" accept="image/*" multiple="multiple" />' +
               imageLimitation +
             '</div>' +
             '<div class="form-group" style="overflow:auto;">' +
               '<label>' + lang.image.url + '</label>' +
               '<input class="note-image-url form-control col-md-12" type="text" />' +
             '</div>';