javascriptckeditor

CKEditor - disable image drag and drop


Problem: When drag and drop images in Firefox into the CKEditor Window, the image are automaticly encoded in base64.

Now i want to disable this. I tried it with:

config.removePlugins = 'dragdrop';

but it's not working at all. Also tried it with a old Plugin (imagepaste), but not working either...

Is there a known solution out there? Thx!


Solution

  • At first I tried to disable Base64 with config.removePlugins = 'dragdrop,basket';, but it didn't work at all.

    Then I found this link, which helped me to solve this problem and wrote a plugin to do the job. Here it is with instructions:

    To use it you have to create a folder inside of ./plugins named dropoff. Then create a file named plugin.js with this content:

    CKEDITOR.plugins.add('dropoff', {
         init: function (editor) {
    
              function rejectDrop(event) {
                  event.data.preventDefault(true);
              };
    
              editor.on('contentDom', function() {
                editor.document.on('drop',rejectDrop);
              });
    
          }
    });
    

    After that, you have to register it on CKEditor's config.js.

    config.extraPlugins = 'dropoff';
    

    If you already using an extra plugin just put a , between them like this:

    config.extraPlugins = 'mypreviousplugin,dropoff';
    

    And be Happy! \o/