jspxcms中使用UEditor插入视频,再次编辑视频丢链问题

jspxcms中使用UEditor插入视频,第一次保存正常,点击修改再次编辑后保存,视频丢失链接.
在存数据时
UEditor在存储时是将Img标签的_url转换成Video标签的src,
但在jspxcms中InfoServiceImpl类中的sanitizeClob方法将Video标签的src属性remove掉了.

private void sanitizeClob(Map<String, String> clobs) {
        if (clobs == null) return;
        for (Map.Entry<String, String> entry : clobs.entrySet()) {
            String v = entry.getValue();
            if (v != null) {
                Document parse = Jsoup.parse(v);
                Elements video = parse.getElementsByTag("video");
                video.removeAttr("src");
                Elements source = parse.getElementsByTag("source");
                String mediaUrl = source.attr("src");
                this.checkMediaUrl(mediaUrl, source);
                Elements body = parse.getElementsByTag("body");
                String html = body.html();
                String replace = html.replace("<body>", "").replace("</body>", "");
                entry.setValue(replace);
            }
        }
    }

存入数据的Clob中的Video标签没有了src属性,而是存在了source标签中,

<p> 
 <video class="edui-upload-video  vjs-default-skin   video-js" controls="" preload="none" width="420" height="280" data-setup="{}"> 
  <source src="/uploads/1/video/public/202007/20200710175019_qq7v2cerph.mp4" type="video/mp4"> 
 </video></p>

在取数据时
查看UEditor中Video标签转换Img标签部分代码

function switchImgAndVideo(root,img2video){
            utils.each(root.getNodesByTagName(img2video ? 'img' : 'embed video'),function(node){
            	debugger;
                var className = node.getAttr('class');
                if(className && className.indexOf('edui-faked-video') != -1){
                    var html = creatInsertStr( img2video ? node.getAttr('_url') : node.getAttr('src'),node.getAttr('width'),node.getAttr('height'),null,node.getStyle('float') || '',className,img2video ? 'embed':'image');
                    node.parentNode.replaceChild(UE.uNode.createElement(html),node);
                }
                if(className && className.indexOf('edui-upload-video') != -1){
                    var html = creatInsertStr( img2video ? node.getAttr('_url') : node.getAttr('src'),node.getAttr('width'),node.getAttr('height'),null,node.getStyle('float') || '',className,img2video ? 'video':'image');
                    node.parentNode.replaceChild(UE.uNode.createElement(html),node);
                }
            })
        }

是将Video标签中的_url属性或者src属性变为Img标签中的_url标签,
而因为jspxcms之前已经将src从Video标签.所以在回显时生成的Img标签的_url属性变为空

<img width="420" height="280" _url class="edui-upload-video  vjs-default-skin  " src="/static/vendor/ueditor/themes/default/images/spacer.gif" style="background:url(/static/vendor/ueditor/themes/default/images/videologo.gif) no-repeat center center; border:1px solid gray;">

再次保存
所以再次保存时Video的src和Source的src都会丢失.

<p>
 <video class="edui-upload-video  vjs-default-skin    video-js" controls="" preload="none" width="420" height="280" data-setup="{}">
  <source src type="video/">
 </video></p>

解决办法
一: 在其回传数据时从Source标签取出src属性加入到Video标签中
二: 将sanitizeClob方法中的video.removeAttr(“src”);注释掉

Document parse = Jsoup.parse(v);
                Elements video = parse.getElementsByTag("video");
                //video.removeAttr("src");//解决丢链
                Elements source = parse.getElementsByTag("source");
                String mediaUrl = source.attr("src");

第一次写,有不足的地方请多多包含,谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值