I'd like to create the same kind of function tumblr has for uploading images and then inserting them directly into the WYSIWYG editor.
I was planning on using uploadify to upload the image, then I am not sure of the method for inserting into the CKEditor.
Has anyone done anything similar or know of a plugin that could do this? Ideally I'd like it to insert the image wherever the text cursor was last placed.
Thanks in advance,
Tim
CKEDITOR.instances['instanceName'].insertHtml('<img src="your image">');
正确的是:
CKEDITOR.instances['instanceName'].insertHtml('<img src="your image"/>');
I'm using dropzone as the image uploader. I've added a button below each image such that when it's clicked an image is inserted at the cursor position in CKEditor. Please see the example below:
myDropzone.on("addedfile", function(file) {
// Hookup image insert button
file.previewElement.querySelector('.insert').onclick = function() {
var element = CKEDITOR.dom.element.createFromHtml('<img src="' + $SCRIPT_ROOT + '/api/files/' + file.id + '?filter=image"/>');
CKEDITOR.instances.body.insertElement(element);
};
});
我正在为CKeditor http://www.ckuploader.com使用漂亮的插件
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.