459 字3 分钟
Fckeditor 插入 MP3 或视频文件
之前有位朋友问我为什么 Fckeditor 不能插入 MP3 音乐的问题,当时真的不知道如何回答他。Fckeditor 不久前刚刚发布了最新的版本 2.5,功能又进一步强化了,我也把博客编辑器给更新了一下。
Google 了一下,还是找到了解决插入 MP3 和视频文件的办法:http://blog.csdn.net/xinma/archive/2007/09/15/1785948.aspx
要说明一下,第一步中的 D.src.endsWith(‘.swf’,true) 在以前的版本可能为 C.src.endsWith(‘.swf’,true)。
修改前注意备份文件,以免造成不必要的麻烦。
一、分别打开/js/fckeditorcode_ie_1.js 和/editor/js/fckeditorcode_gecko_1.js
找到程序代码
D.src.endsWith(".swf", true);替换为:
D.src.endsWith(".swf", true) || D.src.endsWith(".mpg", true) || D.src.endsWith(".asf", true) || D.src.endsWith(".wma", true) || D.src.endsWith(".wmv", true) || D.src.endsWith(".avi", true) || D.src.endsWith(".mov", true) || D.src.endsWith(".mp3", true) || D.src.endsWith(".rm", true) || D.src.endsWith(".ra", true) || D.src.endsWith(".rmvb", true) || D.src.endsWith(".mid", true) || D.src.endsWith(".ram", true);文件格式你根据实际情况增加,基本上面的几种已经可以满足需要了。
二、打开 /editor/dialog/fck_flash/fck_flash.js
1、增加程序代码:
function WinPlayer(url) { var r, re; re = /.(avi|wmv|asf|wma|mid|mp3|mpg)$/i; r = url.match(re); return r;}
function RealPlayer(url) { var r, re; re = /.(.rm|.ra|.rmvb|ram)$/i; r = url.match(re); return r;}
function QuickTime(url) { var r, re; re = /.(mov|qt)$/i; r = url.match(re); return r;}
function FlashPlayer(url) { var r, re; re = /.swf$/i; r = url.match(re); return r;}2、替换程序代码:
e.type = "application/x-shockwave-flash";为:
if (WinPlayer(GetE("txtUrl").value) != null) { e.type = "application/x-mplayer2";}if (RealPlayer(GetE("txtUrl").value) != null) { e.type = "audio/x-pn-realaudio-plugin";}3、替换程序代码:
SetAttribute(e, "type", "application/x-shockwave-flash");SetAttribute(e, "pluginspage", "http://www.macromedia.com/go/getflashplayer");为:
if (WinPlayer(GetE("txtUrl").value) != null) { e.type = "application/x-mplayer2";}if (RealPlayer(GetE("txtUrl").value) != null) { e.type = "audio/x-pn-realaudio-plugin";}