litian

第 5786 位会员

会员
个人信息
  • 加入于 2021-01-25 09:35:48
  • 最后登录时间 3年前
个人成就
  • 发表文章次数 1
  • 发布回复次数 1
  • 个人主页浏览次数 5
fecmall 后台商品编辑器xheditor的媒体上传方法是没有实现吗3年前

那个插件xheditor上传视频等添加到HTML里面是embed标签,对视频支持不友好,我重写了上传方法actionMediaupload,修改了xheditor-1.2.2.min.js文件,改成了插入video标签,上传视频格式改为MP4 代码如下:

<?php

namespace appadmin\local\local_modules\Cms\controllers;
use Yii;

/**
 * @author Terry Zhao <2358269014@qq.com>
 * @since 1.0
 */
class XeditorController extends \fecshop\app\appadmin\modules\Cms\controllers\XeditorController
{

    public function actionMediaupload()
    {
        foreach($_FILES as $FILE){
            list($imgSavedRelativePath, $imgUrl, $imgPath) = Yii::$service->media->saveUploadImg($FILE);
        }
        exit(json_encode(['err' => 0, 'msg' => $imgUrl, 'relative_path' => $imgSavedRelativePath]));
    }
}

xheditor-1.2.2.min.js 文件修改embed标签为video,修改属性autostart为autoplay

        this.showEmbed2 = function(a, b, c, d, e, f, g) {
            var h = $(getLang(b)),
            i = _this.getParent('embed[type="' + c + '"],embed[classid="' + d + '"]'),
            j = $("#xhe" + a + "Url", h),
            k = $("#xhe" + a + "Width", h),
            l = $("#xhe" + a + "Height", h),
            m = $("#xheSave", h);
            f && _this.uploadInit(j, f, g),
            1 === i.length && (j.val(xheAttr(i, "src")), k.val(i.attr("width")), l.val(i.attr("height"))),
            m.click(function() {
                _this.loadBookmark();
                var a = j.val();
                if ("" !== a && "http://" !== a) {
                    var b = k.val(),
                    f = l.val(),
                    g = /^\d+%?$/;
                    g.test(b) || (b = 412),
                    g.test(f) || (f = 300);
                    var h = '<video src="xhe_tmpurl"' + e,
                    m = a.split(" ");
                    if (m.length > 1) {
                        var n, o = h + "",
                        p = [];
                        o += ' width="xhe_width" height="xhe_height" />';
                        for (var q in m) a = m[q].split("||"),
                        n = o,
                        n = n.replace("xhe_tmpurl", a[0]),
                        n = n.replace("xhe_width", a[1] ? a[1] : b),
                        n = n.replace("xhe_height", a[2] ? a[2] : f),
                        "" !== a && p.push(n);
                        _this.pasteHTML(p.join("&nbsp;"))
                    } else 1 === m.length && (a = m[0].split("||"), 0 === i.length && (_this.pasteHTML(h.replace("xhe_tmpurl", a[0] + "#xhe_tmpurl") + " ></video>"), i = $('embed[src$="#xhe_tmpurl"]', _doc)), xheAttr(i, "src", a[0]), i.attr("width", a[1] ? a[1] : b), i.attr("height", a[2] ? a[2] : f))
                } else 1 === i.length && i.remove();
                return _this.hidePanel(),
                !1
            }),
            _this.saveBookmark(),
            console.log(h)
            _this.showDialog(h)
        }
Your Site Analytics