如何在 primeng 编辑器上修复图像 size/dimensions

How to fix image size/dimensions on primeng editor

我正在使用 Angular 8 开发一个应用程序,我在其中使用 prime ng 编辑器。在上传图片按钮中,我想在上传前修复图片大小和尺寸的限制,但我做不到。

有人可以帮我做吗?否则任何使其他组件更简单的建议。

Quill 还没有(至少据我所知,直到今天)有一个实用的方法来控制用户机器上的文件。

但这并不能阻止您定义自己的方式来做到这一点。 internet demonstrating how to upload and display images using JavaScript. With this knowledge, all you have to do is change Quill's native default image behavior. In this case, you can change the behavior of the toolbar image button. And it is not very difficult to get information about the image.

上有数百个教程

要更改 Quill 图像按钮的默认行为,您需要使用 custom handler。这是图像按钮如何更改其行为的简单示例:

function customImageBehavior(){
  console.log('Put your code here!');
}

var quill = new Quill('#editor', {
    theme: 'snow',
    modules: {
      toolbar: {
        container: [['bold' , 'italic' , 'strike' , 'underline'] , ['image' , 'video' , 'link']],
        handlers: {
          'image': customImageBehavior
        }
      }
    }
});
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>

<div id="editor"></div>

哦,别忘了访问 this link 了解更多关于 Quill 的信息。