Browse Source

Move creating thumbnail into `file-added` handler.

Renée Kooi 7 years ago
parent
commit
2d8b1f4e86
1 changed files with 10 additions and 8 deletions
  1. 10 8
      src/core/Core.js

+ 10 - 8
src/core/Core.js

@@ -299,14 +299,6 @@ class Uppy {
           preview: file.preview
         }
 
-        if (Utils.isPreviewSupported(fileTypeSpecific) && !isRemote) {
-          Utils.createThumbnail(file, 200).then((thumbnail) => {
-            this.setPreviewURL(fileID, thumbnail)
-          }).catch((err) => {
-            console.warn(err.stack || err.message)
-          })
-        }
-
         const isFileAllowed = this.checkRestrictions(false, newFile, fileType)
         if (!isFileAllowed) return Promise.reject('File not allowed')
 
@@ -445,6 +437,16 @@ class Uppy {
       this.addFile(data)
     })
 
+    this.on('core:file-added', (file) => {
+      if (Utils.isPreviewSupported(file.type.specific) && !file.isRemote) {
+        Utils.createThumbnail(file, 200).then((thumbnail) => {
+          this.setPreviewURL(file.id, thumbnail)
+        }).catch((err) => {
+          console.warn(err.stack || err.message)
+        })
+      }
+    })
+
     // `remove-file` removes a file from `state.files`, for example when
     // a user decides not to upload particular file and clicks a button to remove it
     this.on('core:file-remove', (fileID) => {