Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can quill limit the size of upload image?

Tags:

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字...',
});
like image 753
willchow Avatar asked Sep 02 '16 16:09

willchow


3 Answers

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
    }
  }
});
like image 82
Ben Winding Avatar answered Nov 17 '22 05:11

Ben Winding


This is not possible at the moment, you would have to create a custom image handler. Feel free to open a feature request.

like image 20
jhchen Avatar answered Nov 17 '22 04:11

jhchen


Yes he can. When you add your image, use :

quill.insertEmbed(0, 'image', value, 'user'); // to insert the image

quill.formatText(0, 1, 'width', '300px'); //to limit the width
like image 22
Salem017 Avatar answered Nov 17 '22 06:11

Salem017