How to configure TinyMCE so that it does not allow the creation of embedded data images?

I have a TinyMCE installation on CMS, and users embed images related to the embedded 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 inserted into some fairly large images, and the contents are stored in a database. This causes the database to grow very quickly in size and there is already a multimedia download component, so how can I simply prevent the editor from accepting this type of image?

+6
source share
1 answer

It depends on what you want. Due to the fact that you cannot ban this element using valid_elements and child_elements, you have to go in other ways.

Case 1 You do not want the user to enter this type of image in a folder.

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

 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 before they are saved to the database.

You can use the tinymce setting in conjunction with onSave to get rid of them.

From what you describe, it seems you need case 1.

+2
source

Source: https://habr.com/ru/post/898163/


All Articles