gpt4 book ai didi

javascript - CKEditor 中的 insertHTML 不仅适用于图像

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:47:34 26 4
gpt4 key购买 nike

我尝试使用以下代码将上传的图像插入到 CKEditor 中,

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

但这行不通。但是当我用这段代码尝试相同的逻辑时

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

Hello world 插入粗体文本。为什么它不适用于 <img>标签?

我找到了这个程序here<img>插入在这个网站上有效。我的网站有什么问题?

最佳答案

添加后问题解决,

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.

替代方案

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

这将添加 <img>属性到允许的标签列表,在这里您需要指定您需要允许的每个标签。 - 来源:Sibbl .

在 config.js 文件中。

关于javascript - CKEditor 中的 insertHTML 不仅适用于图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19487008/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com