问题
I have written my own custom plugin for inserting images in CKEDITOR. I disable the image button in toolbar . I use the editor.insertHtml() function to insert the image from my custom plugin . When I remove the standard image button from the toolset it disables insertion of image tag in the CKEDITOR box . All other html tags are accepted but for the <img/>
tag .
This is my config(without the 'Image' in config.toolbar) :
CKEDITOR.editorConfig = function( config )
{
CKEDITOR.plugins.addExternal('insert_blank','http://localhost:3000/assets/ckeditor/plugins/insert_blank/', 'plugin.js');
CKEDITOR.plugins.addExternal('qimage','http://localhost:3000/assets/ckeditor/plugins/qimage/', 'plugin.js');
config.extraPlugins = 'insert_blank,qimage' ;
config.toolbar =
[
{ name: 'basicstyles', items : [ 'Bold','-','Italic' ] },
{ name: 'insert', items : [ 'insert_blank.btn','-','qimage.btn'
] },
];
config.keystrokes = [
[ CKEDITOR.CTRL + 75, 'InsertBlank' ],
[ CKEDITOR.CTRL + 85, 'qimage' ],
];
config.height = 300 ;
config.width = 350 ;
config.removePlugins = 'elementspath,resize' ;
};
Is there a way to enable image tag insert ?
UPDATE : Worked by adding the following command to the config file :
config.allowedContent = 'b i img[!src,alt,width,height]' ;
回答1:
Have you read how to integrate plugin with Allowed Filter Content? You need to define that your plugin adds button/command which allow img
tag and its attributes. You can also define which tag and its attributes are definitely required for this button/command to be enabled, what will activate/deactivate it when someone will set config.allowedContent
.
回答2:
What you need is just to enable the img[src]
attribute.
So you should use config.extraAllowedContent = 'img[src,alt,width,height]';
the config.allowedContent
will override all the others DOMs.
来源:https://stackoverflow.com/questions/16483344/cant-insert-img-tag-after-adding-custom-plugin-for-image