admin 发表于 2021-5-27 12:34:51

【KindEditor】添加Video标签Mp4视频的方法

修改kindeditor.js具体操作如下:
1.将video添加为不需要过滤过的标签
找到
embed: ['id', 'class', 'src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'],
行下添加一行代码:
video : ['id', 'class', 'src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess','controls'],

2.加上MP4视频类型
找到
if (/\.(swf|flv)(\?|$)/i.test(src)) {
      return 'application/x-shockwave-flash';
}
行下添加:
if (/\.(mp4)(\?|$)/i.test(src)) {
    return 'video/mp4';
}

3.根据视频类型判断
找到
if (/\.(swf|flv)(\?|$)/i.test(src)) {
      return 'application/x-shockwave-flash';
}
行下添加:
if(attrs.type=="video/mp4"){
    var html = '<video ';
    _each(attrs, function(key, val) {
      html += key + '="' + val + '" ';
    });
    html += 'controls="controls"/>';
}
经测试,成功完成。


页: [1]
查看完整版本: 【KindEditor】添加Video标签Mp4视频的方法