InsertHTML in CKEditor does not work only for images

I tried pasting the uploaded image into CKEditor using the following code,

var editor = CKEDITOR.instances.writearticle;
var value = '<img src="images/imagename.jpg">';
editor.insertHtml( value );

But that does not work. But when I try the same logic with this code

var editor = CKEDITOR.instances.writearticle;
var value = '<strong>Hello World</strong>';
editor.insertHtml( value );

Hello world , when bold text is inserted. Why doesn't it work for a tag <img>?

I found this procedure here and the <img>insert works on this site. What is the problem on my site?

+4
source share
3 answers

The problem was resolved after adding,

config.allowedContent = 'img[src,alt,width,height]'; // But be sure to add all the other tags you use in with your Editor. Tags except this will be disabled.

Alternative solution

config.extraAllowedContent = 'img[src,alt,width,height]'

<img> , , . - : Sibbl.

config.js.

+3

:

config.allowedContent = true;

CKEditor

.

+1

You can also write allowedContent here, change the configuration instead.

editor.addCommand( 'XXXDialog', new CKEDITOR.dialogCommand( 'XXXDialog', { allowedContent : 'img[src,alt,width,height]'}) );
0
source

All Articles