I'd like to automatically close the image dialog after uploading an image to the server.
Currently, if a user wants to upload an image using the CKEditor, he encounters the following flow:
1. Open the 'Image' dialog
2. Click 'Upload' tab, and upload image.
3. Set the configuration on 'Image Info' tab.
4. Click 'OK'
What i'd like to do is to trigger the 'onOk' event related code, right after the image submission is done, so that there's no need for the extra mouse click, and of course for the uploaded image to be inserted into the relevant textarea.
Is there a known way to achieve just that?
Any help will be appreciated.
Avner
Currently, if a user wants to upload an image using the CKEditor, he encounters the following flow:
1. Open the 'Image' dialog
2. Click 'Upload' tab, and upload image.
3. Set the configuration on 'Image Info' tab.
4. Click 'OK'
What i'd like to do is to trigger the 'onOk' event related code, right after the image submission is done, so that there's no need for the extra mouse click, and of course for the uploaded image to be inserted into the relevant textarea.
Is there a known way to achieve just that?
Any help will be appreciated.
Avner
Re: Automatically close image dialog after uploading an imag
1. Upload image
2. Automatically insert image into the relevant textarea and close CKEditor's image dialog
I realized that after an image upload, the URL input field on the 'Image Info' tab gets populated with the uploaded image URL. Hitting the 'OK' button runs a validation function and if the mentioned URL input field is empty you get an alert that says the image source is missing.
What I've done is setting the onSelect property of the upload image button, so that once an image is uploaded, put the image URL as the URL input value and trigger the 'OK' button click event. Here's my script:
I had to use jQuery because I didn't find any way to trigger the ok button's click event otherwise. I've tried
but that didn't work. Currently this solution works on FireFox, IE 7-9 and Opera, but on Chrome and Safari it doesn't close the image dialog, and you have to click the OK button in order to close the image dialog.
Honestly, I don't understand how such a basic and fundamental functionality is so complicated to achieve.
Any help will be appreciated.
Avner
Re: Automatically close image dialog after uploading an imag
For others who want the closing dialog after upload, put this into your config.js of ckeditor:
However, calling the last function (for the click) results in:
It seems that CKEditor wants to put the image in the preview, and by calling click event before it seems to break.
any ideas?
PS (Notice): Using dialogDefinition.onShow throws JS error: C.preview not defined.
Where should I include this
Where should I include this code?