问题
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