How to use the plupload.mOxie function in plupload

To help you get started, we’ve selected a few plupload examples, based on popular ways it is used in public projects.

github chenkanqin / evue / src / packages / form / packages / upload / upMixins.js View on Github external
previewImage(file, callback) {//file为plupload事件监听函数参数中的file对象,callback为预览图片准备完成的回调函数
      if (!file || !/image\//.test(file.type)) return; //确保文件是图片

      if (file.type === 'image/gif') {//gif使用FileReader进行预览,因为mOxie.Image只支持jpg和png
        let fr = new plupload.mOxie.FileReader();
//        console.log(fr);
        fr.onload = function () {
          callback(fr.result);
          fr.destroy();
          fr = null;
        };
        fr.readAsDataURL(file.getSource());
      } else {
        let preloader = new plupload.mOxie.Image();
        preloader.onload = function () {
          preloader.downsize(300, 300);//先压缩一下要预览的图片,宽300,高300
          let imgsrc = preloader.type === 'image/jpeg' ? preloader.getAsDataURL('image/jpeg', 80) : preloader.getAsDataURL(); //得到图片src,实质为一个base64编码的数据
          callback && callback(imgsrc); //callback传入的参数为预览图片的url
          preloader.destroy();
          preloader = null;
        };

plupload

Plupload is a JavaScript API for dealing with file uploads it supports features like multiple file selection, file type filtering, request chunking, client side image scaling and it uses different runtimes to achieve this such as HTML 5, Silverlight and F

AGPL-3.0
Latest version published 11 months ago

Package Health Score

70 / 100
Full package analysis