添加OSS SDK

<script type="text/javascript" src="http://gosspublic.alicdn.com/aliyun-oss-sdk-6.0.1.min.js"></script>

OSS配置

//配置替换成你自己的
var client = new OSS({
    region : 'oss-cn-beijing',
    accessKeyId : '',
    accessKeySecret : '',
    bucket : ''
});

配置TinyMCE

tinymce.init({
...省略若干代码...
plugins: [
   'image'
],
toolbar1: "image",
images_upload_handler: function (blobInfo, success, failure) {
    var filename = blobInfo.filename();
    var index = filename.lastIndexOf(".");
    var suffix = filename.substring(index+1, filename.length);
    filename = md5(blobInfo.base64()) + '.' + suffix;
    client.multipartUpload(filename, blobInfo.blob()).then(function (result) {
        if(result.res.requestUrls) {
            success(result.res.requestUrls[0]);
        }
    }).catch(function (err) {
        console.log(err);
    });
},
...省略若干代码...
});

看看效果

点击或者拖拽上传

配置图片属性

插入编辑器

关注公众号,一起学习成长~

xysy.jpg


zhjx922
1.3k 声望120 粉丝

骑驴十三载,不知火烧是何味