I'm using a custom filebrowser for adding images into the CKeditor. When a user selects an image I already fill in the 'alt' automatically which works fine. However if I try to fill the width box with a default value of 250 it seems to be overwritten.
I believe the txtUrl onChange function overwrites my value.
This won't work due to stretching (plugins/image/dialogs/image.js):
I can changing the inputfield with
I even tried to calculate the height myself in changing it in the dialog accordingly
It can kinda work when I do this:
However this isn't a good solution due to the setTimeout usage.
Anyone have some suggestions on how to properly solve this?
I believe the txtUrl onChange function overwrites my value.
This won't work due to stretching (plugins/image/dialogs/image.js):
original.setAttribute( 'width', '250');
I can changing the inputfield with
element = dialog.getContentElement( 'info', 'txtWidth' ); element.setValue( '250');
I even tried to calculate the height myself in changing it in the dialog accordingly
elementWidth = dialog.getContentElement( 'info', 'txtWidth' ); var width = elementWidth.getValue(); elementHeight = dialog.getContentElement( 'info', 'txtHeight' ); var height = elementHeight.getValue(); var newHeight = Math.round(height / width * 250); if ( !isNaN( newHeight ) ) { elementHeight.setValue(Math.round(newHeight)); elementWidth.setValue('250'); }
It can kinda work when I do this:
function resize(dialog) { var width = dialog.getValueOf( 'info', 'txtWidth' ) var height = dialog.getValueOf( 'info', 'txtHeight' ) var newHeight = Math.round(height / width * 250); elementHeight = dialog.getContentElement( 'info', 'txtHeight' ); elementHeight.setValue(Math.round(newHeight)); elementWidth = dialog.getContentElement( 'info', 'txtWidth' ); elementWidth.setValue(250); updatePreview( dialog ); } setTimeout(function(){resize(dialog);},300);
However this isn't a good solution due to the setTimeout usage.
Anyone have some suggestions on how to properly solve this?