CKEDITOR - prevent adding image dimensions as a css style

后端 未结 7 1456
独厮守ぢ
独厮守ぢ 2020-12-14 06:21

How to prevent CKEDITOR from adding image dimensions as a style?

Instead of this:


         


        
相关标签:
7条回答
  • 2020-12-14 06:55

    There is one more way to do this (much simpler), by using Disallowed Content introduced in CKEditor 4.4.0:

    CKEDITOR.replace( 'editor1', {
        disallowedContent : 'img{width,height}'
    } );
    

    or in config.js:

    config.disallowedContent = 'img{width,height}';
    

    This rule will disallow inline styles (width and height) for img element, CKEditor will use attributes instead.

    If for some reason, you will notice that the width/height input elements in the Image dialog window are now gone, set the following as well:

    config.extraAllowedContent = 'img[width,height]';
    
    0 讨论(0)
提交回复
热议问题