WordPress中的CKeditor中没有显示图像

时间:2015-07-18 14:45:31

标签: wordpress ckeditor

我目前在我的WordPress博客中使用Ckeditor作为评论编辑。 我下载了ckeditor.zip文件,并在解压缩zip文件后将所有文件上传到网站的根目录。然后我通过引用http://docs.ckeditor.com/#!/guide/dev_installation将其与评论系统联系起来。除了一些问题外,它运作良好。其中之一是图像没有显示。

例如,如果我通过单击"添加图像"来插入图像。按钮: enter image description here

图像显示在注释输入框中: enter image description here

但是,点击"发表评论"时,图片(通过图片网址插入)不会出现在实际评论中。

我注意到图片以html中的以下形式添加到评论输入框中:

<p><img src="http://www.url.com/...../image_name.jpg" /></p>

供您参考,

1)我将comment_form()部分更改为以下内容:

<?php comment_form(array('comment_field' => '<p class="comment-form-comment">' . 
        '<textarea id="comment" class="ckeditor" name="comment" cols="45" rows="8" aria-required="true"></textarea>' .
        '</p>',
    'comment_notes_after' => '')); ?>

2)我将以下脚本添加到comments.php文件中:

<script type="text/javascript" src="http://www.url-path.com/ckeditor/ckeditor.js"></script>
    <script>

                CKEDITOR.replace( 'comment' );
            </script>

无论如何要解决这个问题?

感谢您的帮助。

注意: 我发现了一个类似的问题(CKEditor images not working),但我不知道如何解决这个问题......

2 个答案:

答案 0 :(得分:0)

尝试在插入数据库之前在CKEditor上发布的内容上运行此函数,

stripslashes($_POST['content']);

答案 1 :(得分:0)

问题与WordPress的设置有关。 我在kses.php中添加了诸如img之类的标签,以便在WordPress中使用它们。 现在它工作正常。

感谢。