MyBB Community Forums

Full Version: How to enable image drag+drop/copy+paste in RinEditor
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This post describes how I tweaked RinEditor to enable copy+paste and drag+drop of images.

  1. Check the version of CkEditor that is being used, e.g. in file jscripts/rin/editor/CHANGES.md
  2. Find the dependencies of the uploadimage plugin on the CkEditor website http://ckeditor.com/addon/uploadimage. The easiest way is to click on the download corresponding to the version you find above. The popup window will inform you about the dependencies
  3. Add the required plugins to ckeditor by unzipping them into jscripts/rin/editor/plugins. These are (for version 4.7.3): button,toolbar,filetools,notification,notificationaggregator,dialog,dialogui,clipboard,lineutils,widgetselection,widget,uploadwidget,uploadimage
  4. Register the plugins with ckeditor in jscripts/rin/editor/config.js:
    a.extraPlugins='button,toolbar,filetools,notification,notificationaggregator,dialog,dialogui,clipboard,lineutils,widgetselection,widget,uploadwidget,uploadimage';


  5. Register the script to handle uploads in config.js (note that the path does not include the "https://your.server" part):
    a.uploadURL='/path_to_your_mybb/ckeditor_upload/upload.php';a.imageUploadUrl='/path_to_your_mybb/ckeditor_upload/upload.php'


  6. Download the mybb ckeditor plugin http://community.mybb.com/mods.php?action=view&pid=73
  7. Unzip somewhere and grab the ckeditor_upload directory. Put it into the path you registered in step 3
  8. In the ckeditor plugin, find the file inc/languages/english/ckeditor.lang.php and put it into the same path in your mybb installation
  9. Change the permission on the ckeditor_upload/uploads directory so that your http server can write files. On Ubuntu, this means
    chown www-data:www-data ckeditor_upload/uploads
  10. Edit ckeditor_upload/upload.php to match the standard ckeditor syntax for uploading files
    • Change
      $_FILES['upl']
    • to
      $_FILES['upload']
    • (six edits)
    • Change
      echo json_encode(array("status" => "error", "message" => $lang->ckeditor_upload_invalid_type));
    • to
      echo json_encode(array("uploaded" => 0, "error" => array("message" => $lang->ckeditor_upload_invalid_type)));
    • (3 edits)
    • Change the success message to
      echo json_encode(array("uploaded" => 1, "fileName" => $_FILES['upload']['name'], "url" => $mybb->settings['bburl'].'/ckeditor_upload/uploads/'.$_FILES['upload']['name']));
    • (1 edit)
Possible improvements:
  • I don't think all the files under ckeditor_upload are actually required
  • Is there a better place for the upload script and upload directory?