I need to retrieve the width from CKEDITOR image property popup when i add the image.
The reason i need to get the width is that i am using CKEDITOR to construct campaign mails.
CKEDITOR sets the prpoerties in a style tag. That is a problem for Outlook because Outlook wats the width of an image as an attribute.
I am pretty new to js and CKEDITOR, but i have found some code that could edit how CKEDITOR inserts the image element. But i still want to be able to set an image size in the CKEDITOR property window.
CKEDITOR.on('dialogDefinition', function(ev) {
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
var editor = ev.editor;
if (dialogName == 'image') {
dialogDefinition.onOk = function(e) {
var width = e.sender.originalElement.$.width;
console.log(width);
if (width >= 600) {
console.log("in");
width = "100%";
} else {
width = width + "px";
}
var imageSrcUrl = e.sender.originalElement.$.src;
var imgHtml = CKEDITOR.dom.element.createFromHtml("<img src=" + imageSrcUrl + " alt='' width='100%' style='width: " + width + "'/> " );
editor.insertElement(imgHtml);
};
}
});
So i want to be able to retrieve the width insrted in the property window when the image is inserted. Can anyone help?