Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 820
user2270134 Avatar asked Oct 20 '22 13:10

user2270134


1 Answers

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/

like image 102
Roger Russel Avatar answered Oct 30 '22 03:10

Roger Russel