1717 <th >#</th >
1818 <th >Thumb</th >
1919 <th >Name</th >
20+ <th >Width</th >
21+ <th >Height</th >
2022 <th >Size</th >
2123 <th >Speed</th >
2224 <th >Status</th >
2527 </thead >
2628 <tbody >
2729 <tr v-if =" !files.length" >
28- <td colspan =" 7 " >
30+ <td colspan =" 9 " >
2931 <div class =" text-center p-5" >
3032 <h4 >Drop files anywhere to upload<br />or</h4 >
3133 <label :for =" name" class =" btn btn-lg btn-primary" >Select Files</label >
4648 <div :class =" {'progress-bar': true, 'progress-bar-striped': true, 'bg-danger': file.error, 'progress-bar-animated': file.active}" role =" progressbar" :style =" {width: file.progress + '%'}" >{{file.progress}}%</div >
4749 </div >
4850 </td >
51+ <td >{{file.width || 0}}</td >
52+ <td >{{file.height || 0}}</td >
4953 <td >{{$formatSize(file.size)}}</td >
5054 <td >{{$formatSize(file.speed)}}</td >
5155
5963 Action
6064 </button >
6165 <div class =" dropdown-menu" >
62- <a :class =" {'dropdown-item': true, disabled: file.active || file.success || file.error === 'compressing'}" href =" #" @click.prevent =" file.active || file.success || file.error === 'compressing' ? false : onEditFileShow(file)" >Edit</a >
66+ <a :class =" {'dropdown-item': true, disabled: file.active || file.success || file.error === 'compressing' || file.error === 'image parsing' }" href =" #" @click.prevent =" file.active || file.success || file.error === 'compressing' ? false : onEditFileShow(file)" >Edit</a >
6367 <a :class =" {'dropdown-item': true, disabled: !file.active}" href =" #" @click.prevent =" file.active ? $refs.upload.update(file, {error: 'cancel'}) : false" >Cancel</a >
6468
6569 <a class =" dropdown-item" href =" #" v-if =" file.active" @click.prevent =" $refs.upload.update(file, {active: false})" >Abort</a >
66- <a class =" dropdown-item" href =" #" v-else-if =" file.error && file.error !== 'compressing' && $refs.upload.features.html5" @click.prevent =" $refs.upload.update(file, {active: true, error: '', progress: '0.00'})" >Retry upload</a >
67- <a :class =" {'dropdown-item': true, disabled: file.success || file.error === 'compressing'}" href =" #" v-else @click.prevent =" file.success || file.error === 'compressing' ? false : $refs.upload.update(file, {active: true})" >Upload</a >
70+ <a class =" dropdown-item" href =" #" v-else-if =" file.error && file.error !== 'compressing' && file.error !== 'image parsing' && $refs.upload.features.html5" @click.prevent =" $refs.upload.update(file, {active: true, error: '', progress: '0.00'})" >Retry upload</a >
71+ <a :class =" {'dropdown-item': true, disabled: file.success || file.error === 'compressing' || file.error === 'image parsing' }" href =" #" v-else @click.prevent =" file.success || file.error === 'compressing' || file.error === 'image parsing ' ? false : $refs.upload.update(file, {active: true})" >Upload</a >
6872
6973 <div class =" dropdown-divider" ></div >
7074 <a class =" dropdown-item" href =" #" @click.prevent =" $refs.upload.remove(file)" >Remove</a >
@@ -454,7 +458,7 @@ export default {
454458 }
455459
456460 if (newValue) {
457- this .$nextTick (function () {
461+ this .$nextTick ( () => {
458462 if (! this .$refs .editImage ) {
459463 return
460464 }
@@ -498,10 +502,10 @@ export default {
498502
499503 // Automatic compression
500504 // 自动压缩
501- if (newFile .file && newFile .type .substr (0 , 6 ) === ' image/' && this .autoCompress > 0 && this .autoCompress < newFile .size ) {
505+ if (newFile .file && newFile .error === " " && newFile . type .substr (0 , 6 ) === ' image/' && this .autoCompress > 0 && this .autoCompress < newFile .size ) {
502506 newFile .error = ' compressing'
503507 const imageCompressor = new ImageCompressor (null , {
504- convertSize: Infinity ,
508+ convertSize: 1024 * 1024 ,
505509 maxWidth: 512 ,
506510 maxHeight: 512 ,
507511 })
@@ -516,13 +520,12 @@ export default {
516520 }
517521
518522
519- if (newFile && (! oldFile || newFile .file !== oldFile .file )) {
520-
523+ if (newFile && newFile .error === " " && newFile .file && (! oldFile || newFile .file !== oldFile .file )) {
521524 // Create a blob field
522525 // 创建 blob 字段
523526 newFile .blob = ' '
524- let URL = window .URL || window .webkitURL
525- if (URL && URL . createObjectURL ) {
527+ let URL = ( window .URL || window .webkitURL )
528+ if (URL ) {
526529 newFile .blob = URL .createObjectURL (newFile .file )
527530 }
528531
@@ -533,6 +536,20 @@ export default {
533536 newFile .thumb = newFile .blob
534537 }
535538 }
539+
540+ // image size
541+ // image 尺寸
542+ if (newFile && newFile .error === ' ' && newFile .type .substr (0 , 6 ) === " image/" && newFile .blob && (! oldFile || newFile .blob !== oldFile .blob )) {
543+ newFile .error = ' image parsing'
544+ let img = new Image ();
545+ img .onload = () => {
546+ this .$refs .upload .update (newFile, {error: ' ' , height: img .height , width: img .width })
547+ }
548+ img.οnerrοr = (e ) => {
549+ this .$refs .upload .update (newFile, { error: ' parsing image size' })
550+ }
551+ img .src = newFile .blob
552+ }
536553 },
537554
538555 // add, update, remove File Event
@@ -602,6 +619,7 @@ export default {
602619
603620 let data = {
604621 name: this .editFile .name ,
622+ error: ' ' ,
605623 }
606624 if (this .editFile .cropper ) {
607625 let binStr = atob (this .editFile .cropper .getCroppedCanvas ().toDataURL (this .editFile .type ).split (' ,' )[1 ])
0 commit comments