2016-07-12, 06:56 AM
This post describes how I tweaked RinEditor to enable copy+paste and drag+drop of images.
- Check the version of CkEditor that is being used, e.g. in file jscripts/rin/editor/CHANGES.md
- 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
- 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
- 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';
- 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'
- Download the mybb ckeditor plugin http://community.mybb.com/mods.php?action=view&pid=73
- Unzip somewhere and grab the ckeditor_upload directory. Put it into the path you registered in step 3
- In the ckeditor plugin, find the file inc/languages/english/ckeditor.lang.php and put it into the same path in your mybb installation
- 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
- 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)
- Change
- 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?