ckeditor-ckfinder default attributes (width and height) to uploaded images

后端 未结 4 1569
名媛妹妹
名媛妹妹 2021-01-28 12:04

When I upload images using ckfinder in the ckeditor the image displays nicely using css width & height. I would like images to have default width and height attributes. How

4条回答
  •  攒了一身酷
    2021-01-28 13:05

    Set the default width and height while clicking "ok" button. Replace the user entered height & width values with default height & width (Override "OnOK" Function)

    In config.js

     CKEDITOR.on('dialogDefinition', function (ev) {
    
        var dialogName = ev.data.name,
            dialogDefinition = ev.data.definition;
    
        if (dialogName == 'image') {
            var onOk = dialogDefinition.onOk;
    
            dialogDefinition.onOk = function (e) {
                var width = this.getContentElement('info', 'txtWidth');
                width.setValue('200');//Set Default Width
    
                var height = this.getContentElement('info', 'txtHeight');
                height.setValue('200');////Set Default height
    
                onOk && onOk.apply(this, e);
            };
        }
    });
    

提交回复
热议问题