将图像插入 tinymce 编辑器

将图像插入 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 + '"/>');

这是演示.