Quantcast
Channel: MyBB Community Forums - Tutorials
Viewing all articles
Browse latest Browse all 690

How to enable image drag+drop/copy+paste in RinEditor

$
0
0
This post describes how I tweaked RinEditor to enable copy+paste and drag+drop of images.

  1. Add the required plugins to ckeditor by unzipping them into jscripts/rin/editor/plugins. These are: button,toolbar,notification,notificationaggregator,lineutils,widget,uploadwidget,uploadimage. For example the button plugin can be found at http://ckeditor.com/addon/button
  2. Register the plugins with ckeditor in jscripts/rin/editor/config.js:

    a.extraPlugins='button,toolbar,notification,notificationaggregator,lineutils,widget,uploadwidget,uploadimage';
  3. Register the script to handle uploads in config.js:

    a.uploadURL='/path_to_your_mybb/ckeditor_upload/upload.php';a.imageUploadUrl='/path_to_your_mybb/ckeditor_upload/upload.php'
  4. Download the mybb ckeditor plugin http://community.mybb.com/mods.php?action=view&pid=73
  5. Unzip somewhere and grab the ckeditor_upload directory. Put it into the path you registered in step 3
  6. In the ckeditor plugin, find the file inc/languages/english/ckeditor.lang.php and put it into the same path in your mybb installation
  7. 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
  8. 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?

Viewing all articles
Browse latest Browse all 690

Trending Articles