我尝试使用旧的嵌入代码将YouTube视频添加到TinyMCE中,它运行正常。有些用户可能没有意识到他们必须点击YouTube嵌入代码链接中的旧嵌入代码选项才能添加。
我想让用户轻松一点,让他们直接复制新的嵌入代码并将其粘贴到TinyMCE上,然后就可以了。
新的嵌入代码如下例所示:
<iframe title="YouTube video player" width="640" height="390"
src="http://www.youtube.com/embed/VvJ037b_kLs"
frameborder="0" allowfullscreen></iframe>
如何让TinyMCE接受使用iframe的新版YouTube嵌入代码?
我正在开发CakePHP网站版本。
答案 0 :(得分:9)
我认为使用“extended_valid_elements”比编辑原始设置更好。
答案 1 :(得分:8)
默认情况下,出于安全原因,TinyMCE会过滤掉iframe标记。您可以将此标记及其属性添加到允许的html元素列表中。
请参阅http://tinymce.moxiecode.com/wiki.php/Configuration:valid_elements
默认规则集:
tinyMCE.init({
// ... other configurations
valid_elements : "@[id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|"
+ "onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|"
+ "onkeydown|onkeyup],a[rel|rev|charset|hreflang|tabindex|accesskey|type|"
+ "name|href|target|title|class|onfocus|onblur],strong/b,em/i,strike,u,"
+ "#p,-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|"
+ "src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,"
+ "-blockquote,-table[border=0|cellspacing|cellpadding|width|frame|rules|"
+ "height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|"
+ "height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,"
+ "#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor"
+ "|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div,"
+ "-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face"
+ "|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite],"
+ "object[classid|width|height|codebase|*],param[name|value|_value],embed[type|width"
+ "|height|src|*],script[src|type],map[name],area[shape|coords|href|alt|target],bdo,"
+ "button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|"
+ "valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method],"
+ "input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value],"
+ "kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value],"
+ "q[cite],samp,select[disabled|multiple|name|size],small,"
+ "textarea[cols|rows|disabled|name|readonly],tt,var,big"
});
将以下内容添加到列表的末尾
,iframe[src|title|width|height|allowfullscreen|frameborder]
我不建议允许用户在公共网站中嵌入iframe标记。