开发者

How can I set up TinyMCE so that it won't allow inline data images?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜