如何强制TinyMCE使用flash youtube嵌入而不是iframe?
我正在使用TinyMCE 3.4.9,并试图强制媒体插件始终使用Flash嵌入而不是iFrame嵌入 出于安全原因,我不想允许任何iframe的嵌入 我已经手动格式化了URL,以获得一个Flash嵌入对象,而不是iFrame对象 即如何强制TinyMCE使用flash youtube嵌入而不是iframe?,flash,iframe,youtube,tinymce,Flash,Iframe,Youtube,Tinymce,我正在使用TinyMCE 3.4.9,并试图强制媒体插件始终使用Flash嵌入而不是iFrame嵌入 出于安全原因,我不想允许任何iframe的嵌入 我已经手动格式化了URL,以获得一个Flash嵌入对象,而不是iFrame对象 即 闪存嵌入: iFrame嵌入: 是否有一种方法可以执行以下两种操作之一: 更改嵌入文件/URL字段后,修改URL,以便默认情况下嵌入Flash对象。(http://www.youtube.com/watch?v=fWNaR-rxAic将被转换为) 更改对you
- 闪存嵌入:
- iFrame嵌入:
<script language="javascript" type="text/javascript">
tinyMCE.init(
{
paste_remove_styles : true,
gecko_spellcheck : true,
theme_advanced_font_sizes : "1,2,3,4,5",
extended_valid_elements:"script[charset|defer|language|src|type]",
theme : "advanced",
mode: "exact",
plugins: "inlinepopups,emotions,searchreplace,paste,media",
elements : "blogcontent",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,sub,sup,|,fontselect,fontsizeselect,forecolor,|,link,unlink,|,backcolor",
theme_advanced_buttons2 : "justifyleft,justifycenter,justifyright,|,search,replace,|,image,charmap,emotions, media,|,undo,redo",
theme_advanced_buttons3 : "",
theme_advanced_resize_horizontal : false,
theme_advanced_resizing : false,
file_browser_callback : 'file_browser',
relative_urls : false,
remove_script_host : false,
paste_retain_style_properties : "font-size,color,font-family,background-color",
setup :
function(ed)
{
ed.onKeyUp.add(
function(ed, e)
{
ed.nodeChanged();
}
);
}
}
);
</script>
tinyMCE.init(
{
粘贴\删除\样式:true,
gecko_拼写检查:对,
主题高级字体大小:“1,2,3,4,5”,
扩展的|有效|元素:“script[charset | defer | language | src | type]”,
主题:“高级”,
模式:“精确”,
插件:“inlinepopups、情感、搜索替换、粘贴、媒体”,
元素:“博客内容”,
主题\高级\工具栏\位置:“顶部”,
主题\高级\工具栏\对齐:“左”,
主题高级按钮1:“粗体、斜体、下划线、删除线、sub、sup、|、字体选择、字体大小选择、前景色、|、链接、取消链接、|、背景色”,
主题_高级_按钮2:“左对齐、中对齐、右对齐、|、搜索、替换、|、图像、字符映射、情感、媒体、|、撤消、重做”,
主题\高级\按钮3:“”,
主题\u高级\u调整大小\u水平:false,
主题\u高级\u大小调整:错误,
文件浏览器回调:“文件浏览器”,
相对URL:false,
删除\u脚本\u主机:false,
粘贴\保留\样式\属性:“字体大小、颜色、字体系列、背景色”,
设置:
功能(ed)
{
ed.onKeyUp.add(
功能(ed,e)
{
ed.nodeChanged();
}
);
}
}
);
谢谢,因为我还没有找到强制将youtube视频嵌入flash的方法,所以我为iframe安全问题创建了一个解决方案 我已将iframe添加到允许的标记列表中,并且在保存内容后向用户显示内容时,我已将白名单过滤器应用于任何iframe,这些iframe将拉出白名单中没有src的任何iframe
function filterIframeBySource($text, $allowed_sources)
{
// regex to retrieve just the iframes
$regex = '/<iframe[0-9a-zA-Z \.\/=>:\-"]*<\/iframe>/';
$matches = array();
$reg_pos = preg_match($regex, $text, $matches);
// loop through each match and check the src for that iframe
$src_expression = '/ src="http:\/\/('.str_replace('.', '\.', implode('|', $allowed_sources)).')[0-9a-zA-Z\/-]*" /';
foreach($matches as $match)
{
$src_pos = preg_match($src_expression, $match);
if($src_pos !== false && $src_pos === 0)
$text = str_replace($match, '[Removed iFrame]', $text);
}
return $text;
}
函数filterIframeBySource($text,$allowed\u sources)
{
//regex只检索iframe
$regex='/:\-“]*/”;
$matches=array();
$reg_pos=preg_match($regex,$text,$matches);
//循环检查每个匹配项,并检查该iframe的src
$src_expression='/src=“http:\/\/('.str_replace('.','\.',introde('.|',$allowed_sources)))[0-9a-zA-Z\/-]*“/”;
foreach($matches作为$match进行匹配)
{
$src_pos=preg_match($src_表达式,$match);
如果($src\u pos!==false&&$src\u pos==0)
$text=str_replace($match,“[Removed iFrame]”,$text);
}
返回$text;
}
希望这能有所帮助。因为我还没有找到强制将youtube视频嵌入flash的方法,所以我为iframe安全问题创建了一个解决方案 我已将iframe添加到允许的标记列表中,并且在保存内容后向用户显示内容时,我已将白名单过滤器应用于任何iframe,这些iframe将拉出白名单中没有src的任何iframe
function filterIframeBySource($text, $allowed_sources)
{
// regex to retrieve just the iframes
$regex = '/<iframe[0-9a-zA-Z \.\/=>:\-"]*<\/iframe>/';
$matches = array();
$reg_pos = preg_match($regex, $text, $matches);
// loop through each match and check the src for that iframe
$src_expression = '/ src="http:\/\/('.str_replace('.', '\.', implode('|', $allowed_sources)).')[0-9a-zA-Z\/-]*" /';
foreach($matches as $match)
{
$src_pos = preg_match($src_expression, $match);
if($src_pos !== false && $src_pos === 0)
$text = str_replace($match, '[Removed iFrame]', $text);
}
return $text;
}
函数filterIframeBySource($text,$allowed\u sources)
{
//regex只检索iframe
$regex='/:\-“]*/”;
$matches=array();
$reg_pos=preg_match($regex,$text,$matches);
//循环检查每个匹配项,并检查该iframe的src
$src_expression='/src=“http:\/\/('.str_replace('.','\.',introde('.|',$allowed_sources)))[0-9a-zA-Z\/-]*“/”;
foreach($matches作为$match进行匹配)
{
$src_pos=preg_match($src_表达式,$match);
如果($src\u pos!==false&&$src\u pos==0)
$text=str_replace($match,“[Removed iFrame]”,$text);
}
返回$text;
}
希望这有帮助