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/