How to do add/change functionality without a config.js file?

Jan 3, 2014 at 7:18 PM
Curious how something like this: http://stackoverflow.com/questions/2051896/ckeditor-prevent-adding-image-dimensions-as-a-css-style

Adding a Rule to config.js is possible using the latest CKEditor on DNN?
CKEDITOR.on('instanceReady', function (ev) {
// Ends self closing tags the HTML4 way, like <br>.
ev.editor.dataProcessor.htmlFilter.addRules(
    {
        elements:
        {
            $: function (element) {
                // Output dimensions of images as width and height
                if (element.name == 'img') {
                    var style = element.attributes.style;

                    if (style) {
                        // Get the width from the style.
                        var match = /(?:^|\s)width\s*:\s*(\d+)px/i.exec(style),
                            width = match && match[1];

                        // Get the height from the style.
                        match = /(?:^|\s)height\s*:\s*(\d+)px/i.exec(style);
                        var height = match && match[1];

                        if (width) {
                            element.attributes.style = element.attributes.style.replace(/(?:^|\s)width\s*:\s*(\d+)px;?/i, '');
                            element.attributes.width = width;
                        }

                        if (height) {
                            element.attributes.style = element.attributes.style.replace(/(?:^|\s)height\s*:\s*(\d+)px;?/i, '');
                            element.attributes.height = height;
                        }
                    }
                }
Specifically we aim to remove the style attribute on images and replace it with specific height/width attributes instead. (we're using the CK Editor on a bootstrap 3 based site and are having issues with the editor adding in inline styles for images).

Thanks in advance for any direction or support on this one.
Coordinator
Jan 11, 2014 at 2:32 PM
In version 2.00.09 (BETA 1 released today). You can define a custom js file. For exactly your solution. This file will be loaded with the editor.
Marked as answer by tha_watcha on 1/11/2014 at 7:47 AM