CKEditor图像插件配置

3

我真的需要删除图片插件中的这些属性,我只需要允许用户设置src属性,仅此而已。但是,由于JavaScript和Ckeditor不是我的强项,因此我无法想出如何实现。有人知道吗?

我正在使用CKEditor 4.3.1

在此输入图片描述

2个回答

5

HTML

<textarea id="editor" name="editor1">&lt;p&gt;Initial value.&lt;/p&gt;</textarea>

脚本

<script type="text/javascript">
    CKEDITOR.on('dialogDefinition', function (ev) {
        // Take the dialog name and its definition from the event data.
        var dialogName = ev.data.name;
        var dialogDefinition = ev.data.definition;
        // Check if the definition is from the dialog we're
        // interested in (the 'image' dialog).
        if (dialogName == 'image') {
            // Get a reference to the 'Image Info' tab.
            var infoTab = dialogDefinition.getContents('info');
            // Remove unnecessary widgets/elements from the 'Image Info' tab.
            infoTab.remove('browse');
            infoTab.remove('txtHSpace');
            infoTab.remove('txtVSpace');
            infoTab.remove('txtBorder');
            infoTab.remove('txtAlt');
            infoTab.remove('txtWidth');
            infoTab.remove('txtHeight');
            infoTab.remove('htmlPreview');
            infoTab.remove('cmbAlign');
            infoTab.remove('ratioLock');
        }
    });
    CKEDITOR.replace('editor');
</script>

这个可行吗?通常图像对话框依赖于某些字段的存在,如果您尝试删除它们,则根本无法工作。 - AlfonsoML
是的,它可以工作。这些是额外的配置字段,如果不存在也不会破坏图像插件。 - Bhalchandra K
很好他们已经修复了这个问题,因为正如我所说,它曾经会破坏插件:https://dev59.com/T2jWa4cB1Zd3GeqPnyiA - AlfonsoML
之前不知道这个有问题,谢谢提醒。 - Bhalchandra K

-2

我建议您使用ckfinder来浏览图片。 以下是在调用coeditor时使用的代码:

    <script type="text/javascript">
        //<![CDATA[

        // This call can be placed at any point after the
        // <textarea>, or inside a <head><script> in a
        // window.onload event handler.

CKEDITOR.replace('testoEditor', {
    filebrowserBrowseUrl : '../../ckfinder/ckfinder.html',
    filebrowserImageBrowseUrl : '../../ckfinder/ckfinder.html?Type=Images',
    width : '505',
    height : '400',

});

//]]>
    </script>

确切地说,因为ckeditor不上传文件,所以您需要一个外部脚本来完成这项工作,您可以集成ckfinder来浏览图片。 - Antonio Romano
我不希望他们上传任何文件,只需要设置外部图片链接即可。 - Silverfall05
我需要相同的插件->图像,但只是摆脱我划掉的那些东西。 - Silverfall05

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接