How to add default classname on the images i uploa

2019-08-30 04:13发布

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

1条回答
Evening l夕情丶
2楼-- · 2019-08-30 05:06

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/

查看更多
登录 后发表回答