Summernote Show Images that have been uploaded to a folder

前端 未结 3 1357
时光说笑
时光说笑 2021-01-15 03:04

I am using the really nice Summernote Editor for a little webapp. Instead of using the default inline base64 code for images I am storing the images in a folder.

I

相关标签:
3条回答
  • 2021-01-15 03:25

    In the new version of summernote onImageUpload callback is called only with files argument. It means that editor is not available.

    You can insert an image with:

    $('.summernote').summernote("insertImage", url, filename);
    

    In your case:

    $('.summernote').summernote("insertImage", data, 'filename');
    
    0 讨论(0)
  • 2021-01-15 03:27

    I did it using codeigniter may be this help someone.

     $(function() {
              $('.summernote').summernote({
                  onImageUpload: function(files, editor, $editable) {
                  sendFile(files[0],editor,$editable);
                  }  
                });
    
               function sendFile(file,editor,welEditable) {
                  data = new FormData();
                  data.append("file", file);
                   $.ajax({
                   url: "http://localhost/fourm/media/editorupload",
                   data: data,
                   cache: false,
                   contentType: false,
                   processData: false,
                   type: 'POST',
                   success: function(data){  
                    editor.insertImage(welEditable, data);              
                },
                   error: function(jqXHR, textStatus, errorThrown) {
                   console.log(textStatus+" "+errorThrown);
                  }
                });
               }
        });

    0 讨论(0)
  • 2021-01-15 03:35

    You must use "callbacks: {}" method. like this:

    $('.summernote').summernote({
        height: 500,
        tabsize: 4,
        callbacks: {
            onImageUpload: function(files, editor, $editable) {
                console.log('onImageUpload');
                sendFile(files[0],editor,$editable);
            }
        }});
    
    0 讨论(0)
提交回复
热议问题