CKEditor:允许视频嵌入代码

发布于 2024-10-20 16:55:34 字数 169 浏览 3 评论 0原文

我正在使用 CKEditor,并希望允许插入来自 YouTube、Vimeo 等的嵌入代码。 CKEditor 将所有标签转换为等效的 HTML Chars,这很好,但我希望它对此类内容进行例外处理。 iFrame 似乎就是现在的做法,那么我如何告诉 CKEditor 不理会 iFrame 标签呢?

谢谢。

I am using CKEditor and want to allow the insertion of embed code from YouTube, Vimeo etc.
CKEditor turns all tags into HTML Chars equivalent, which is good, but I want it to make exceptions for this kind of content. iFrames seem to be how it's done nowadays, so how can I tell CKEditor to leave iFrame tags alone?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

请止步禁区 2024-10-27 16:55:35

不。这些答案都不完全准确。该插件对于你想做的事情来说太过分了。对以下文本进行项目范围搜索:extraAllowedContent 并将 'iframe[!src];' 添加到任何其他允许的内容中。然后添加以下内容:allowedContent: true,

No. None of these answers are exactly accurate. The plugin is overkill for what you want to do. Do a project wide search for the following text: extraAllowedContent and add 'iframe[!src];' to whatever other allowed content is there. Then add the following: allowedContent: true,

ま柒月 2024-10-27 16:55:35

CKEditor 附带一个 config.js 文件。在此文件中,将参数 config.allowedContent 设置为 true

例如,

CKEDITOR.editorConfig = function( config )
{
    config.toolbar_TRiGCustom =
    [
        ['Bold','Italic','Underline','-','JustifyLeft','JustifyCenter','-','Blockquote'],
        ['FontSize'],
        ['Undo','Redo'],
        ['Link','Unlink','Image','Table'],
        ['NumberedList', 'BulletedList'],
        ['Source'],
        ['Maximize']
    ];
    config.toolbar = 'TRiGCustom';
    config.forcePasteAsPlainText = true;
    config.forceSimpleAmpersand = true;
    config.resize_enabled = false;
    config.toolbarCanCollapse = false;
    config.scayt_autoStartup = true;
    config.language = 'en';
    config.uiColor = '#76BC49';
    config.width = '97%';
    config.extraPlugins = 'maximize';
    config.allowedContent = true;
};

我在 Amixa 博客。该博客文章似乎是为名为 ASPMAKER 的特定 CMS 编写的,并且还建议对该 CMS 中的特定 ASP 文件进行调整,但对 CKEditor 配置的此编辑是通用的,并且适用于 CKEditor,无论您在何处使用它。 config.allowedContent = true; 行就是您所需要的。

CKEditor comes with a config.js file. In this file, set the paramater config.allowedContent to true.

For example,

CKEDITOR.editorConfig = function( config )
{
    config.toolbar_TRiGCustom =
    [
        ['Bold','Italic','Underline','-','JustifyLeft','JustifyCenter','-','Blockquote'],
        ['FontSize'],
        ['Undo','Redo'],
        ['Link','Unlink','Image','Table'],
        ['NumberedList', 'BulletedList'],
        ['Source'],
        ['Maximize']
    ];
    config.toolbar = 'TRiGCustom';
    config.forcePasteAsPlainText = true;
    config.forceSimpleAmpersand = true;
    config.resize_enabled = false;
    config.toolbarCanCollapse = false;
    config.scayt_autoStartup = true;
    config.language = 'en';
    config.uiColor = '#76BC49';
    config.width = '97%';
    config.extraPlugins = 'maximize';
    config.allowedContent = true;
};

I found this solution on the Amixa Blog. The blog post seems to be written for a specific CMS called ASPMAKER, and also recommends tweaks to specific ASP files in that CMS, but this edit to CKEditor config is generic, and applies to CKEditor wherever you're using it. The line config.allowedContent = true; is all you need.

删除会话 2024-10-27 16:55:35

最简单的方法是启用“源”按钮。如果您使用完整的工具栏(不是基本的),它已经存在。

The easy way is enabling the 'Source' button. If you use the full toolbar (not basic) it is already present.

风月客 2024-10-27 16:55:35

启用“源”按钮并不能解决此问题。然后可以粘贴诸如“iframe”之类的嵌入代码,但如果您再次返回并编辑该字段,CKeditor 将删除它。您首先需要配置 CKeditor 以允许 iframe 嵌入。

Enabling the "Source" button does not solve this problem. Embed code such as "iframe" can then be pasted, but if you come back and edit the field a second time, CKeditor will have stripped it. You need to configure CKeditor to allow iframe embedding in the first place.

我的鱼塘能养鲲 2024-10-27 16:55:34

在寻找相同的解决方案时刚刚发现了您的问题。这是我发现的。基本上,它会像“图像”按钮一样向您的工具栏添加一个按钮,但它会弹出一个框供您将 YouTube、Vimeo 等的嵌入代码粘贴到其中。看起来效果很好。

http://www.fluidbyte.net/ index.php?view=embed-youtube-vimeo-etc-into-ckeditor

编辑:链接到 archive.org:
http://web.archive.org/web/20110805213357/http://www.fluidbyte.net/index.php?view=embed-youtube-vimeo-etc-into-ckeditor

Just found your question while searching for the same solution. Here is what I found. Basically, it adds a button to your toolbar like the Image button, but it pops up a box for you to paste the embed code from YouTube, Vimeo etc. into. Seems to work pretty well.

http://www.fluidbyte.net/index.php?view=embed-youtube-vimeo-etc-into-ckeditor

Edit: Link to archive.org:
http://web.archive.org/web/20110805213357/http://www.fluidbyte.net/index.php?view=embed-youtube-vimeo-etc-into-ckeditor

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文