我如何设置TinyMCE,使其不允许嵌入数据图像? [英] How can I set up TinyMCE so that it won't allow inline data images?

查看:1560
本文介绍了我如何设置TinyMCE,使其不允许嵌入数据图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CMS上安装了TinyMCE,用户已经粘贴了内嵌数据类型的图像。这种东西:

 < img src =data:image / gif; base64,R0lGODlhEAAOALMAAOazToeHh0tLS / 7LZv / 0jvb29t / f3 // UB / 
/ ge8WSLf / RHF / 3kdbW1mxsbP // MF /// yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcpp
V0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj / gAwXEQA7\"
宽度= 16 HEIGHT = 14 ALT = 嵌入式文件夹图标 >

他们正在粘贴一些相当大的图片,并将内容存储在数据库中。这使得数据库的规模增长非常快,已经有一个媒体上传组件,所以我怎样才能避免编辑接受这种类型的图像呢?

解决方案

这取决于你想要什么。
由于您不能使用valid_elements和child_elements来禁止这种元素,所以您必须采取其他方式。



案例1 :您不希望用户输入这种类型的图片。



您需要使用粘贴插件并设置参数paste_pre

  paste_preprocess:function(pl,o){
window.console&& console.log('Object',o);
window.console&& console.log('Content:',o.content);

//修改此处的内容 - >删除那种图像
o.content = o.content.substr(...)
}

第二种情况:您希望图像在被保存到数据库中之前被过滤掉。

您可以使用tinymce 设置参数与onSave结合来获取摆脱他们。



从你所描述的看来,你似乎想要案例1。

I have a TinyMCE installation on a CMS and the users have been pasting in images which are of the inline data type. This kind of thing:

<img src="data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/f3//Ub/
/ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcpp
V0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj/gAwXEQA7" 
width="16" height="14" alt="embedded folder icon">

They are pasting in some pretty large images, and the content gets stored in a database. This is making the database grow very quickly in size, and there is already a media upload component available, so how can I simply prevent the editor from accepting this type of image?

解决方案

This depends on what you want. Due to the fact that you won't be able to disallow this kind of element using valid_elements and child_elements you will have to go other ways.

Case 1: You do not want user to enter this kind of image onPaste.

You will need to use the paste plugin and set the parameter paste_pre

paste_preprocess : function(pl, o) {
    window.console && console.log('Object', o);
    window.console && console.log('Content:', o.content);

    // modify o.content here -> remove images of that kind
    o.content = o.content.substr(...)
}

Case 2: You want the images to be filtered out before they are getting saved into the DB.

You may use the tinymce setup paramter combined with onSave to get rid of them.

From what you describe you seem to be wanting Case 1.

这篇关于我如何设置TinyMCE,使其不允许嵌入数据图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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