Ckeditor 如何允许img标签?

Ckeditor 如何允许img标签?,ckeditor,wysiwyg,fckeditor,Ckeditor,Wysiwyg,Fckeditor,我已经创建了只插入外部图像的自定义图像插件。但是如果我禁用默认的图像插件,那么img标签就不会出现在表单中。为什么? 这是我的插件: CKEDITOR.plugins.add( 'img', { init: function( editor ) { editor.addCommand( 'insertImg', { exec : function( editor ) {

我已经创建了只插入外部图像的自定义图像插件。但是如果我禁用默认的图像插件,那么img标签就不会出现在表单中。为什么?

这是我的插件:

CKEDITOR.plugins.add( 'img',
{
    init: function( editor )
    {
        editor.addCommand( 'insertImg',
            {
                exec : function( editor )
                {    
                    var imgurl=prompt("Insert url image");
                    editor.insertHtml('<img src="'+imgurl+'" />');
                }
            });
        editor.ui.addButton( 'img',
        {

            label: 'Insert img',
            command: 'insertImg',
            icon: this.path + 'images/aaa.png'
        } );
    }
} );
CKEDITOR.plugins.add('img',
{
init:函数(编辑器)
{
editor.addCommand('insertImg',
{
执行:函数(编辑器)
{    
var imgurl=提示(“插入url图像”);
编者:insertHtml(“”);
}
});
editor.ui.addButton('img',
{
标签:“插入img”,
命令:“insertImg”,
图标:this.path+'images/aaa.png'
} );
}
} );

您在addButton配置中设置了错误的命令名。您需要设置:

editor.addCommand( 'insertImg', {
         ...
     }
);
以及
editor.ui.addButton()

UPD:
有些麻烦:

您需要将插件与CKEditor 4.1中引入的ACF-Advanced Content Filter集成

这里有一个有用的指南-

基本上,您是在向编辑器介绍一个特性。这个特性需要告诉编辑器它是如何在HTML中表示的,所以启用这个特性时应该允许什么

在最简单的情况下,当您有一个执行命令的按钮时,您只需要定义界面的两个属性:
allowedContent
requiredContent

例如:

editor.addCommand('insertImg'{
requiredContent:'img[src]',//启用此功能所需的最小HTML。
allowedContent:'img[!src,alt,width,height],//此功能可以创建的最大HTML。
exec:函数(编辑器){
var imgurl=提示(“插入url图像”);
编者:insertHtml(“”);
}
} );

现在,当这个按钮被添加到工具栏上时,该功能将自动启用,并且允许使用图像。

我为您创建了一些小提琴。一切正常:
editor.addCommand( 'insertImg', {
    requiredContent: 'img[src]', // Minimal HTML which this feature requires to be enabled.
    allowedContent: 'img[!src,alt,width,height]', // Maximum HTML which this feature may create.
    exec: function( editor ) {    
        var imgurl=prompt("Insert url image");
        editor.insertHtml('<img src="'+imgurl+'" />');
    }
} );