本文介绍了ckeditor没有读取媒体嵌入代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ckingitor的media embed插件。它工作正常,代码正确保存在数据库和youtube,soundcloud etd。玩家在页面上显示ok。但是当用户转到他的管理,他可以编辑信息,在里面和与标签的文本不显示,因此当用户点击保存按钮时,所有以前保存的iframe将被擦除,只有休息的格式化文本将被保存。有没有办法在ckeditor中显示iframe代码?

解决方案

我假设你使用CKEditor 4.1.x (ACF)。最可能的是,你使用不同的编辑器进行前端/后端编辑。



每个插件都会扩展属性,具有标签,属性和类的自身规则。使用这些规则,编辑器会自动删除不需要的内容,例如,如果您的前端编辑器允许< iframe> ,因为它已经插入媒体插件,插件将从内容中删除< iframe>



此外,ACF还会观察您的工具栏配置,如果你包括插件,但不想在工具栏中的按钮,按钮提供的任何内容(即< iframe> )也将被禁止在编辑器的输出。



您可以轻松地检查编辑者是否接受< iframes> 。基本上调用以下内容并查看输出:

  CKEDITOR.instances.yourInstance.filter.check('iframe'); 
>>>> true //允许

如果 false ,那么您的问题有几种解决方案:


  1. 在后端编辑器中启用mediaembed插件(使用工具栏中的按钮)。

  2. 扩展 config.extraAllowedContent ,让它再次回来。


$ b b

虽然第一个):

  allowedContent:'iframe [*]'//代表:iframe元素属性

如果您将以下内容添加到后端编辑器的配置中,加载媒体插件:

  config.extraAllowedContent ='iframe [*]'
/ pre>

如果此解决方案不适用于您,请提供编辑器配置和CKEditor版本,以便人们可以帮助您。


I use the media embed plugin for ckeditor. It works fine, the code is correctly saved in the database and youtube, soundcloud etd. players display ok on the page. But when the user goes to his administration, where he can edit the info, the text inside and with the tags is not showing, so when the user clicks on the save button, all previously saved iframes will be "erased" and only the rest of the formatted text will be saved. Is there any way to display the iframe code in the ckeditor?

解决方案

I assume that you use CKEditor 4.1.x which comes with Advanced Content Filter (ACF). Most likely, the point is that you use different editors for frontend/backend editing.

Each plugin extends allowedContent property with own rules for tags, attributes and classes. Using those rules, editor automatically strips out undesired contents, so for example, if your fronted editor allows <iframe> because it has mediaembed plugin loaded, then your backend editor without this plugin will remove your <iframe> from the content.

Furthermore, ACF also observes your toolbar configuration so even if you include the plugin but you don't want the button in the toolbar, any content the button provides (i.e. <iframe>) will also be disallowed in editor's output.

You can easily check whether your editor accept <iframes>. Basically call the following and see the output:

CKEDITOR.instances.yourInstance.filter.check( 'iframe' );
>>> true // it's allowed

If it's false, then there are several solutions for your problem:

  1. Enable mediaembed plugin in your backend editor (with button in the toolbar).
  2. Extend config.extraAllowedContent to have it back again.

While the first solution is straightforward, the second one might be tricky for you. allowedContent rule for mediaembed plugin is as follows (see plugin's code):

allowedContent: 'iframe[*]' // stands for: iframe element with any attribute

If you add the following to your backend editor's config, you will have iframes back in your content without loading mediaembed plugin:

config.extraAllowedContent = 'iframe[*]'

If this solution doesn't work for you, please provide editor configs and CKEditor version so that people could help you.

这篇关于ckeditor没有读取媒体嵌入代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 12:50