TinyMCE删除youtube链接

时间:2011-04-08 13:28:25

标签: html symfony1 tinymce sanitization

我有一个带有“内容”textarea的symfony表单,它使用tinyMCE。

当我写:

<p class="centre">
<object width="640" height="385">
<param name="movie" value="http://www.youtube.com/v/qOP2V_np2c0&hl=en_US&fs=1&rel=0">
</param>
<param name="allowFullScreen" value="true">
</param>
<param name="allowscriptaccess" value="always">
</param>
<embed src="http://www.youtube.com/v/qOP2V_np2c0&hl=en_US&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385">
</embed>
</object>
</p>

它保存为:

<p class="centre">
<object width="640" height="385">
<param name="movie" value="http://www.youtube.com/v/qOP2V_np2c0&amp;hl=en_US&amp;fs=1&amp;rel=0" />
<param name="allowFullScreen" value="true" />
<param name="allowscriptaccess" value="always" />
</object>
</p>

2 个答案:

答案 0 :(得分:1)

只需在param配置数组的closed键中添加init标记:

tinyMCE.init({
    ...
    closed: /^(br|hr|input|meta|img|link|param|area|param)$/,
    ...
});

Source

答案 1 :(得分:1)

我必须在* extended_valid_elements *中添加一些元素,以便它不会删除Flash内容。

tinyMCE.init({
    mode : “textareas”,
    editor_selector:“mceEditor”,
    theme : “advanced”,
    theme_advanced_buttons1 : “bold,italic,underline,strikethrough,|,forecolor,backcolor,|,link,unlink,image,code”,
    theme_advanced_buttons2 : “”,theme_advanced_buttons3 : “”,theme_advanced_buttons4 : “”,
    theme_advanced_resizing : true, tab_focus : “:prev,:next”,
    extended_valid_elements : “object[width|height|classid|codebase],param[name|value],embed[src|type|width|height|flashvars|wmode]“
});

http://syedgakbar.wordpress.com/2008/01/28/adding-flash-embed-support-in-tinymce-editor/

上找到答案