[英]Insert an image into a tinymce editor
I have a tinymce text box on my html page. 我的html页面上有一个tinymce文本框。 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. 我希望能够单击此表中的图像并将其插入timymce文本框中。 How might I go about doing this? 我该怎么做呢?
I've used the command 我用过这个命令
tinyMCE.execCommand('mceInsertContent', false, '<img alt="Smiley face" height="42" width="42" src="' + sr + '"/>');
to insert the image in tinyMCE after extracting the URL from the image's src
. 从图像的src
提取URL后,在tinyMCE中插入图像。
Note that you need to pass the CSS style of the image to tinyMCE in the command. 请注意,您需要在命令中将图像的CSS样式传递给tinyMCE。
EDIT: 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 + '"/>');
编辑:对于Tiny MCE 4.x,插入图像代码可以简化为: tinymce.activeEditor.insertContent('<img alt="Smiley face" height="42" width="42" src="' + sr + '"/>');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.