我正在使用CKEditor並希望允許插入來自YouTube,Vimeo等的嵌入代碼。 CKEditor將所有標記轉換爲等效的HTML Chars,這很好,但我希望它爲這種內容。 iFrames似乎是現在這樣做的,所以我如何告訴CKEditor離開iFrame標籤?CKEditor:允許視頻嵌入代碼
謝謝。
我正在使用CKEditor並希望允許插入來自YouTube,Vimeo等的嵌入代碼。 CKEditor將所有標記轉換爲等效的HTML Chars,這很好,但我希望它爲這種內容。 iFrames似乎是現在這樣做的,所以我如何告訴CKEditor離開iFrame標籤?CKEditor:允許視頻嵌入代碼
謝謝。
剛剛找到你的問題,同時尋找相同的解決方案。這是我發現的。基本上,它會向您的工具欄中添加一個按鈕,如圖像按鈕,但它會彈出一個框供您粘貼來自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
啓用 「源」 按鈕並不能解決這個問題。像iframe這樣的嵌入代碼可以被粘貼,但是如果你第二次回來編輯這個字段,CKeditor就會剝離它。你需要配置CKeditor以允許iframe嵌入到第一位。
「您需要配置CKeditor以允許iframe嵌入到第一位。」怎麼樣? – Randell
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 Blog該溶液中。該博文似乎是爲特定的CMS編寫的,稱爲ASPMAKER,並且還建議對該CMS中的特定ASP文件進行調整,但對CKEditor配置的編輯是通用的,並且適用於任何使用CKEditor的CKEditor。行config.allowedContent = true;
是你所需要的。
TL; DR - add config.allowedContent = true; – Ben
如果您想禁用高級內容過濾器,請將'CKEDITOR.config.allowedContent'設置爲'true'。所有可用的編輯器功能將被激活,並且輸入數據不會被過濾。請注意,禁用ACF時不能使用CKEDITOR.config.disallowedContent。 如果您只使用'CKEDITOR.config.allowedContent = true',您將允許用戶執行令人討厭的事情。 –
不,這些答案都不準確。該插件是爲你想做的事情矯枉過正。在項目範圍內搜索以下文本:extraAllowedContent
並將'iframe[!src];'
添加到其他允許的內容。然後添加以下內容:allowedContent: true,
太好了,謝謝。 – Francisc
我試圖嵌入時遇到錯誤400。爲了解決這個問題,我只是將下面的代碼(在第30行)從plugin.js改爲''
404找不到,can你請給我更新的新鏈接? – Nemke