quill-image-uploader icon indicating copy to clipboard operation
quill-image-uploader copied to clipboard

Return img src path with no delay

Open henpin opened this issue 3 years ago • 2 comments

I added the following code to my app

          imageUploader: {
            upload: async (file) => {
              if (!this.$utils.checkUploadFileSize(file)) { // If over 1MB
                this.$snackbar.show("can not upload file over 1MB");
                return "/img/no-image.png";
              }
              return await storage.articleImage.upload(file);
            },
          },

If file size is over 1MB, then I want the behavior as below

  1. insert <img src="/img/no-image.png">
  2. disappear image-loader inserted by quill-image-uploader

But the image-loader dosen't disappear (and it appears forever). Because quill-image-uploader seems to need seconds delay before return path.

I want to return path with no delay.

henpin avatar Apr 30 '21 08:04 henpin

upload method should return a promise. Try:

          imageUploader: {
            upload: async (file) => {
                if (!this.$utils.checkUploadFileSize(file)) { // If over 1MB
                  this.$snackbar.show("can not upload file over 1MB");
                  return new Promise(resolve=>{
                    resolve("/img/no-image.png");
                  })
                }
              return await storage.articleImage.upload(file);
            },
          },

hswimmer avatar Mar 08 '22 21:03 hswimmer

I added the following code to my app

          imageUploader: {
            upload: async (file) => {
              if (!this.$utils.checkUploadFileSize(file)) { // If over 1MB
                this.$snackbar.show("can not upload file over 1MB");
                return "/img/no-image.png";
              }
              return await storage.articleImage.upload(file);
            },
          },

If file size is over 1MB, then I want the behavior as below

  1. insert <img src="/img/no-image.png">
  2. disappear image-loader inserted by quill-image-uploader

But the image-loader dosen't disappear (and it appears forever). Because quill-image-uploader seems to need seconds delay before return path.

I want to return path with no delay.

I noticed that too, so I always introduce a delay until the promise is resolved.

maykon-oliveira avatar Jan 04 '24 20:01 maykon-oliveira