Search code examples
summernotelaravel-backpack

How to integrate Summernote with S3 image uploading?


I would like to integrate Summernote's image upload button to upload my images to S3 (actually, I'm using DigitalOcean Spaces, but it's currently using S3 lib, so the integration will be the same, I guess)

I have already run the publish config file command

php artisan backpack:publish crud/fields/summernote

then, in crud_fields_scripts hook, I inserted this code:

$('#summernote').summernote({
onImageUpload: uploadImages
});

but looks like the onImageUpload hook is not gonna run (window.alert works fine though)

please guide me further from this point, thank you in advance 🙏🏻


Solution

  • I just have to hook into the already-existed callback tag in the published config file, as follows:

    let summernotCallbacks = { 
         onChange: function(contents, $editable) {
              element.val(contents).trigger('change');
         },
         onImageUpload: uploadImages
    }