将图像插入 tinymce 编辑器 [英] Insert an image into a tinymce editor

查看:41
本文介绍了将图像插入 tinymce 编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 html 页面上有一个 tinymce 文本框.在此文本框下,我有一个包含我的文件系统的表格,我可以在其中导航以找到我的图像.我希望能够单击此表中的图像并将其插入到 timymce 文本框中.我该怎么做?

I have a tinymce text box on my html page. Under this text box I have a table with my file system in which I can navigate to locate my images. I would like to be able to click on an image in this table and have it inserted in the timymce text box. How might I go about doing this?

推荐答案

我用过这个命令

tinyMCE.execCommand('mceInsertContent', false, '<img alt="Smiley face" height="42" width="42" src="' + sr + '"/>');

从图像的src中提取URL后将图像插入tinyMCE.

to insert the image in tinyMCE after extracting the URL from the image's src.

注意需要在命令中将图片的CSS样式传递给tinyMCE.

Note that you need to pass the CSS style of the image to tinyMCE in the command.

对于 Tiny MCE 4.x,插入图像代码可以简化为: tinymce.activeEditor.insertContent('<img alt="Smiley face" height="42" width="42"src="' + sr + '"/>');

for Tiny MCE 4.x, the insert image code can be simplified to: tinymce.activeEditor.insertContent('<img alt="Smiley face" height="42" width="42" src="' + sr + '"/>');

这是演示.

这篇关于将图像插入 tinymce 编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆