上传图片并直接插入CKEditor

发布于 2024-08-29 07:13:00 字数 359 浏览 3 评论 0原文

我想创建与 tumblr 相同的功能,用于上传图像,然后将它们直接插入到所见即所得编辑器中。

我打算使用 uploadify 上传图像,然后我不确定插入到 CKEditor 中的方法。

有没有人做过类似的事情或知道可以做到这一点的插件?理想情况下,我希望它将图像插入到文本光标最后放置的位置。

上传图片并直接插入文本区域 http://www.freeimagehosting.net/uploads/ 06217dcebb.png

提前致谢,

蒂姆

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.

Upload an image and directly insert it into a text area http://www.freeimagehosting.net/uploads/06217dcebb.png

Thanks in advance,

Tim

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

自由如风 2024-09-05 07:13:01
CKEDITOR.instances['instanceName'].insertHtml('<img src="your image">');
CKEDITOR.instances['instanceName'].insertHtml('<img src="your image">');
℡Ms空城旧梦 2024-09-05 07:13:01

正确的是:

CKEDITOR.instances['instanceName'].insertHtml('<img src="your image"/>');

Correct is:

CKEDITOR.instances['instanceName'].insertHtml('<img src="your image"/>');
深爱成瘾 2024-09-05 07:13:01

我使用 dropzone 作为图像上传器。我在每个图像下方添加了一个按钮,这样当单击它时,图像就会插入到 CKEditor 中的光标位置。请看下面的例子:

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);
    };
}); 

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);
    };
}); 
夜吻♂芭芘 2024-09-05 07:13:01

我正在为 CKeditor 使用很好的插件 http://www.ckuploader.com

I'm using nice plugin for CKeditor http://www.ckuploader.com

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文