如何防止CKEditor将img的width,height属性转换为内联样式?

时间:2014-09-30 00:26:34

标签: javascript html image ckeditor inline-styles

对不起,如果这似乎是一个老问题,但是现在,我被困在这个问题并且无法解决它超过3个小时,所以请告诉我如何解决这个问题。

我最近在网页上添加了一个CKEditor。问题是它会将width元素的heightattributes img转换为内联样式。这些属性在服务器端设置,我希望我保留它们。我尝试了许多可能的解决方案,但它们似乎已经过时了。

这是我使用的脚本:

<script language="JavaScript"  type="text/javascript">
 CKEDITOR.config.toolbar = [
    { name: 'document', items : [ 'Source','-','Save','DocProps','Preview' ] },
    { name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', '-', 'Undo', 'Redo' ] },
    { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'Find', 'Replace', '-', 'SelectAll', ] },
    { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
    { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv',
    '-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
    { name: 'insert', items: [ 'Image', 'Table', 'HorizontalRule', 'SpecialChar',  ] },
    { name: 'styles', items: ['Format', 'Font', 'FontSize' ] },
    { name: 'colors', items: [ 'TextColor' ] },
    { name: 'tools', items: ['Maximize', 'About' ] }
];
CKEDITOR.config.height = 500;
CKEDITOR.config.contentsLangDirection = 'rtl';

CKEDITOR.replace( 'htmlp1', {
    allowedContent:
        'img(left,right)[!src,alt,width,height];' 
} );
            </script>

拜托,你能清楚告诉我该怎么办?

非常感谢。

0 个答案:

没有答案