Skip autoOrientImage for non-JPEG images

This commit is contained in:
Daniel Gasienica
2018-02-13 15:07:09 -05:00
parent 58eac38301
commit 2ca7cdbc31
2 changed files with 15 additions and 0 deletions

View File

@@ -6,6 +6,8 @@
'use strict';
window.Whisper = window.Whisper || {};
const { MIME } = window.Signal.Types;
Whisper.FileSizeToast = Whisper.ToastView.extend({
templateName: 'file-size-modal',
render_attributes: function() {
@@ -31,6 +33,7 @@
this.thumb = new Whisper.AttachmentPreviewView();
this.$el.addClass('file-input');
this.window = options.window;
this.previewObjectUrl = null;
},
events: {
@@ -136,6 +139,12 @@
case 'audio': this.addThumb('images/audio.svg'); break;
case 'video': this.addThumb('images/video.svg'); break;
case 'image':
if (!MIME.isJPEG(file.type)) {
this.previewObjectUrl = URL.createObjectURL(file);
this.addThumb(this.previewObjectUrl);
break;
}
window.autoOrientImage(file)
.then(dataURL => this.addThumb(dataURL));
break;
@@ -271,6 +280,11 @@
},
clearForm: function() {
if (this.previewObjectUrl) {
URL.revokeObjectURL(this.previewObjectUrl);
this.previewObjectUrl = null;
}
this.thumb.remove();
this.$('.avatar').show();
this.$el.trigger('force-resize');

View File

@@ -80,6 +80,7 @@
window.Signal.Types = window.Signal.Types || {};
window.Signal.Types.Attachment = require('./js/modules/types/attachment');
window.Signal.Types.Message = require('./js/modules/types/message');
window.Signal.Types.MIME = require('./js/modules/types/mime');
// We pull this in last, because the native module involved appears to be sensitive to
// /tmp mounted as noexec on Linux.