wangEditor icon indicating copy to clipboard operation
wangEditor copied to clipboard

没有上次图片的后端接口,可以直接使用base64存入html里面吗?

Open the-lemonboy opened this issue 1 year ago • 8 comments

问题描述

没有上次图片的后端接口,可以直接使用base64存入html里面吗?

wangEditor 版本

wangeditor5

是否查阅了文档 ?

(文档链接 www.wangeditor.com

the-lemonboy avatar Aug 29 '24 02:08 the-lemonboy

可以,用 base64 限制好图片大小就好,具体看文档

cycleccc avatar Aug 29 '24 03:08 cycleccc

可以,用 base64 限制好图片大小就好,具体看文档

image 没有设置上传地址会报错呀

the-lemonboy avatar Aug 29 '24 03:08 the-lemonboy

base64LimitSize 这个配置添加了吗

cycleccc avatar Aug 29 '24 03:08 cycleccc

添加了

the-lemonboy avatar Aug 29 '24 03:08 the-lemonboy

确实只写个配置不够用,还得要拦截上传逻辑,这个在文档里应该也写了

cycleccc avatar Sep 03 '24 06:09 cycleccc

请问是在上传图片那部分吗?好像没有看到相关文档内容。

the-lemonboy avatar Sep 04 '24 03:09 the-lemonboy

如果你的需求是不管图片大小都使用base64,可以试试自定义上传

 const editorConfig: Partial<IEditorConfig> = {
        MENU_CONF: {
            uploadImage: {
                async customUpload(file: File, insertFn) {
                const reader = new FileReader();
                reader.readAsDataURL(file);
                reader.addEventListener('load', ()=> {
                    console.log(reader.result, 'reader.result')
                    insertFn(reader.result);
                });
              }
            }
        }
    }

fanggz2017 avatar Sep 05 '24 03:09 fanggz2017

如果你的需求是不管图片大小都使用base64,可以试试自定义上传

 const editorConfig: Partial<IEditorConfig> = {
        MENU_CONF: {
            uploadImage: {
                async customUpload(file: File, insertFn) {
                const reader = new FileReader();
                reader.readAsDataURL(file);
                reader.addEventListener('load', ()=> {
                    console.log(reader.result, 'reader.result')
                    insertFn(reader.result);
                });
              }
            }
        }
    }

感谢!我去试试。

the-lemonboy avatar Sep 07 '24 04:09 the-lemonboy