Check out this code snippet that removes the width and height attributes from image tags and style tags to ensure responsiveness by adding a specific class to the image.
CKEDITOR.config.disallowedContent = 'img{width,height}';
CKEDITOR.on('instanceReady', function (ev) {
ev.editor.dataProcessor.htmlFilter.addRules({
elements: {
$: function(element) {
if (element.name == 'img') {
if (element.attributes.style) {
element.attributes.style = element.attributes.style.replace(/(height|width)[^;]*;/gi, '');
}
}
if (!element.attributes.style) {
delete element.attributes.style;
}
return element;
}
}
});
});