fecmall 后台商品编辑器xheditor的媒体上传方法是没有实现吗

bug问题 · litian · 于 3年前 发布 · 1366 次阅读
class XeditorController extends CmsController
{
    public $enableCsrfValidation = false;

    // cms/staticblock/imageupload
    public function actionImageupload()
    {
        //$imgUrl = 'http://fecshop.appadmin.fancyecommerce.com/assets/9e150533/dwz_jui-master/themes/default/images/logo.png';
        foreach ($_FILES as $FILE) {
            list($imgSavedRelativePath, $imgUrl, $imgPath) = Yii::$service->image->saveUploadImg($FILE);
        }
        exit(json_encode(['err' => 0, 'msg' => $imgUrl, 'relative_path' => $imgSavedRelativePath]));
    }

    public function actionFlashupload()
    {
    }

    public function actionLinkupload()
    {
    }

    public function actionMediaupload()
    {
    }
}

控制器中的actionMediaupload媒体上传方法没有实现吗?

共收到 3 条回复
Fecmall#13年前 0 个赞

只实现了图片上传,其他的没有实现

您可以自己写一个分享一下。

litian#23年前 1 个赞

那个插件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)
        }
qwzjoyr#33年前 0 个赞

@2楼,是不是只改这两个文件就可以了?

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics