Auto-orient preview images

See: #998
This commit is contained in:
Daniel Gasienica 2018-02-09 16:44:30 -05:00
parent 06dba5eb8f
commit c77063afc6
1 changed files with 8 additions and 6 deletions

View File

@ -134,8 +134,14 @@
case 'audio': this.addThumb('images/audio.svg'); break;
case 'video': this.addThumb('images/video.svg'); break;
case 'image':
this.oUrl = URL.createObjectURL(file);
this.addThumb(this.oUrl);
window.loadImage(
file,
autoOrientedCanvas => {
const objectUrl = autoOrientedCanvas.toDataURL();
this.addThumb(objectUrl);
},
{orientation: true},
);
break;
default:
this.addThumb('images/file.svg'); break;
@ -259,10 +265,6 @@
},
clearForm: function() {
if (this.oUrl) {
URL.revokeObjectURL(this.oUrl);
this.oUrl = null;
}
this.thumb.remove();
this.$('.avatar').show();
this.$el.trigger('force-resize');