How to add default classname on the images i upload with CKEditor?

旧巷老猫 提交于 2019-12-11 16:43:58

问题


Like the topic says: How to add default classname on the images i upload with CKEditor? Cant relly find any information regarding this


回答1:


CKEDITOR.on( 'instanceReady', function( ev )
{
	var editor = ev.editor;
 	var dataProcessor = editor.dataProcessor,
	            htmlFilter = dataProcessor && dataProcessor.htmlFilter;
	            htmlFilter.addRules(
	            {
	                elements:
	                {
	                    $: function (element) {
	                         if (element.name == 'img') {
	                            if (!element.attributes['class']){
	                                	element.attributes['class'] = "helloworld";
	                            }
	                        }
	                        return element;
	                    }
	                }
	            });
	
});

http://jsfiddle.net/z6y8q6rm/2/



来源:https://stackoverflow.com/questions/26587645/how-to-add-default-classname-on-the-images-i-upload-with-ckeditor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!