在KindEditor中編輯可上傳MP4
mp4視訊格式上傳:
找到 kindeditor-all.js
- 在 htmlTags 配置中新增:
video : [‘id’, ‘class’, ‘src’, ‘width’, ‘height’, ‘type’, ‘loop’, ‘autostart’, ‘quality’, ‘.width’,
‘.height’, ‘align’, ‘allowscriptaccess’,‘controls’],
這是配置白名單, 為了防止kindeditor編輯器無法識別video標籤.
- 修改 _mediaImg()方法
原始碼
function _mediaImg(blankPath, attrs) {
var width = attrs.width,
height = attrs.height,
type = attrs.type || _mediaType(attrs.src),
srcTag = _mediaEmbed(attrs),
style = ‘’;
if (/\D/.test(width)) {
style += ‘width:’ + width + ‘;’;
} else if (width > 0) {
style += ‘width:’ + width + ‘px;’;
}
if (/\D/.test(height)) {
style += ‘height:’ + height + ‘;’;
} else if (height > 0) {
style += ‘height:’ + height + ‘px;’;
}
var html = ‘<img class="’ + _mediaClass(type) + ‘" src="’ + blankPath + '" ';
if (style !== ‘’) {
html += ‘style="’ + style + '" ';
}
html += ‘data-ke-tag="’ + escape(srcTag) + ‘" alt="" />’;
return html;
}
修改為,程式碼塊部分為修改的程式碼
function _mediaImg(blankPath, attrs) {
var width = attrs.width,
height = attrs.height,
type = attrs.type || _mediaType(attrs.src),
srcTag = _mediaEmbed(attrs),
style = ‘’;
if (/\D/.test(width)) {
style += ‘width:’ + width + ‘;’;
} else if (width > 0) {
style += ‘width:’ + width + ‘px;’;
}
if (/\D/.test(height)) {
style += ‘height:’ + height + ‘;’;
} else if (height > 0) {
style += ‘height:’ + height + ‘px;’;
}
if (attrs.src.indexOf(".mp4")!=-1) {
var html = '<video src="'+attrs.src+'" controls="controls" width="'+width+'" height="'+height+'" class="' + _mediaClass(type) + '" type="video/mp4" ';
html += '>您的瀏覽器太老了, 不支援視訊播放。請下載最新瀏覽器!</video>'
return html;
}else{
var html = '<img class="' + _mediaClass(type) + '" src="' + blankPath + '" ';
if (style !== '') {
html += 'style="' + style + '" ';
}
html += 'data-ke-tag="' + escape(srcTag) + '" alt="" />';
}
return html;
}
attrs.src.indexOf(".mp4")!=-1 如果是mp4格式視訊,就將標籤替換成標籤,這樣才能播放
如果修改到這裡的話, 會出現編輯器無法編輯, 上傳後的視訊無法刪除.
這裡拼接video視訊地址的時候, 要加入編輯器識別標籤
:
var html = '<p></p><p><video src="'+attrs.src+'" controls="controls" width="'+width+'" height="'+height+'" class="' + _mediaClass(type) + '" type="video/mp4" ';
html += '>您的瀏覽器太老了, 不支援視訊播放。請下載最新瀏覽器!</video></p><p></p>'
相關文章
- thinkphp編輯器kindeditorPHP
- KindEditor編輯器的圖片上傳問題
- js 操作kindeditor編輯器JS
- AngularJS教程十一—— 文字編輯器kindeditorAngularJS
- 線上編輯器KindEditor看樣子不錯
- 剛才把kindeditor線上編輯器做成視覺化UBB編輯模式了視覺化模式
- HTML編輯器 KindEditor 4.1.10 釋出,相容IE11HTMLIE11
- 程式碼控制 textarea 控制元件是否為KindEditor 編輯框控制元件
- 在Progress編輯器中批次編譯程式編譯
- 織夢kindeditor編輯器圖片上傳增加圖片alt屬性和title屬性的方法
- 在gridview中編輯時 用dropdownlistView
- Extjs4.2x與富文字框編輯器KindEditor的整合JS
- 預設後臺Kindeditor編輯器在ie11下,彈出層js有問題,點上傳圖片後,圖片上傳彈出層不出現IE11JS
- [BUG反饋]Kindeditor編輯器在IE11下點上傳圖片後,圖片上傳彈出層不出現,建議官網更新新版本IE11
- Angular在sublime編輯器中如何新增註釋???Angular
- 在vim中顯示並編輯十六進位制
- 採用Kindeditor編輯器時,提交、修改無法入庫的原因和解決辦法
- asp.net無法獲取kindeditor文字編輯器內容的解決辦法ASP.NET
- 在VB中編輯資料庫和電子表格 (轉)資料庫
- Laravel 5-KindEditor 一款值得推薦的最具情懷的 HTML 文字編輯器LaravelHTML
- xheditor編輯器上傳功能實現
- 在sql*plus裡編輯SQL命令SQL
- js input 不可編輯可傳值設定JS
- Linux中編輯影片字幕Linux
- React 中整合 Markdown編輯器React
- kindeditor 上傳圖片 自動調整尺寸大小
- C# / VB.NET 在PPT中建立、編輯PPT SmartArt圖形C#
- 在Spring2.5中定製自己的屬性編輯器Spring
- 取KindEditor中的textarea的值區不到的解決方案,固定kindEditor的高度
- .Net通用大檔案上傳類(可上傳大檔案,vs2005)
- 檔案上傳之解析漏洞編輯器安全
- 如何在 Linux 中編輯字幕Linux
- DbForge Studio for SQL Server入門教程:在表編輯器中建立表SQLServer
- ASP 能都做到,在WEB中編輯WORD 文件!! JSP 如何實現?WebJS
- [提問交流]onethink中kindeditor問題
- 教你如何完美儲存Html編輯器編輯過的文字到Word中HTML
- 編輯
- 編譯並裁剪 FFmpeg 在 Android 上做視訊編輯編譯Android