quill 可以限制上传图片的大小吗? [英] Can quill limit the size of upload image?

查看:589
本文介绍了quill 可以限制上传图片的大小吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

图片大,反应慢,一定要限制!怎么做?谢谢!

As the image is large, the response is slow, so must limit! How to do it? thanks!

var editor = new Quill('#postContent', {
  modules: {
    toolbar: '#toolbar-container'
  },
  theme: 'snow',
  //placeholder: '不超过3000字...',
});

推荐答案

当然可以,我制作了一个 Quill 模块,用于在将图像添加到 Quill 编辑器(粘贴、上传、拖动)后压缩.您也可以调整压缩和压缩质量.

Sure can, I made a Quill module to compress images once they are added to the Quill editor (Pasted, Uploaded, Dragged). You can adjust the compression and quality of the compression too.

https://github.com/benwinding/quill-image-compress

import ImageCompress from 'quill-image-compress';

Quill.register('modules/imageCompress', ImageCompress);

const quill = new Quill(editor, {
  // ...
  modules: {
    // ...
    imageCompress: {
      quality: 0.7, // default
      maxWidth: 1000, // default
      maxHeight: 1000, // default
      imageType: 'image/jpeg', // default
      debug: true, // default
    }
  }
});

这篇关于quill 可以限制上传图片的大小吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆