【问题标题】:Embedding YouTube video with new iframe embed code in TinyMCE在 TinyMCE 中使用新的 iframe 嵌入代码嵌入 YouTube 视频
【发布时间】:2011-06-26 17:15:07
【问题描述】:

我尝试了将 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 网站。

【问题讨论】:

  • 你能给我们新的嵌入代码吗?
  • lmao, john... 你想回答你的问题,你应该提供人们要求的所有信息。为什么要别人去做研究来回答你的问题?
  • dogmatic69,老实说,你读过“TITLE”这个问题吗?我已经更新了正文内容。
  • Thariama,对不起,我想我误解了你的陈述,因为你误解了我的陈述!我的意思是我“估计”如果用户能够直接从youtube 发布新的嵌入代码而不点击旧的嵌入代码选项,而在我的网站上发布,那该多好。我还在寻找答案。

标签: php cakephp youtube tinymce


【解决方案1】:

我认为使用“extended_valid_elements”比编辑原始设置更好。

看到:TinyMCS - extended_valid_elements

【讨论】:

    【解决方案2】:

    出于安全原因,默认情况下 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 标签。

    【讨论】:

    猜你喜欢
    • 2016-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-08
    • 1970-01-01
    • 2012-05-02
    • 2020-03-01
    • 2020-04-19
    相关资源
    最近更新 更多