I'm trying to write a plugin to upload images to imgur. This is how the dialog window looks like.
And here's the code I've written so far.
CKEDITOR.plugins.add( 'imgurUpload', { init : function ( editor ) { editor.addCommand( 'imgurUploadDialog', new CKEDITOR.dialogCommand( 'imgurUploadDialog' ) ); //creating the button displayed in the toolbar editor.ui.addButton( 'ImgurUpload', { label : 'Upload an image to imgur', command : 'imgurUploadDialog', icon : this.path + 'images/icon.png' }); //creating the dialog window CKEDITOR.dialog.add( 'imgurUploadDialog', function( editor ) { return { title : 'Upload an Image', minWidth : 400, minHeight: 150, contents : [ { id : 'main', label : 'Upload', elements : [ { type : 'file', id : 'upload', label : 'Select the image you want to upload', size : 45, validate : CKEDITOR.dialog.validate.notEmpty( 'The file path cannot be empty' ), required : true }, { type : 'fileButton', id : 'uploadButton', label : 'Upload to imgur', 'for' : [ 'main', 'upload' ], filebrowser : { action : 'QuickUpload', params : { type : 'Images', currentFolder : '/folder/' }, onSelect: function ( fileUrl, errorMessage ) { alert( 'The selected file path is ' + fileUrl ); alert( 'This error ocurred' + errorMessage ); } } } ] } ] }; }); } });
My question is how can I capture the Upload button's event to execute the code to upload the image?
Is it the event onSelect? When I select an image and click the Upload button the following error message shows up in the dialog window. (imgur Test is the folder where I have these files)
Not Found
The requested URL /imgur Test/undefined was not found on this server.
This is my very first crack at writing a plugin soo I'm a bit lost how to do this. Any help would be greatly appreciated.
Thank you
Upload images to a remote server
Hi Isuru,
I'm interested by this plugin. Did you get it work? or do you have a more complete version?
Thanks in advances,
simo