From f4d3392687168c237441b29140c7968b49dbef9e Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Fri, 9 Feb 2018 14:35:02 -0500 Subject: [PATCH] Replace `ImageView` `el` with auto-oriented `canvas` See: #998 --- js/views/attachment_view.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/js/views/attachment_view.js b/js/views/attachment_view.js index 5c4d135c7..ce2f53879 100644 --- a/js/views/attachment_view.js +++ b/js/views/attachment_view.js @@ -15,8 +15,19 @@ var ImageView = Backbone.View.extend({ tagName: 'img', - initialize: function(dataUrl) { - this.dataUrl = dataUrl; + initialize: function(objectUrl, contentType, blob) { + loadImage(blob, autoOrientedCanvas => { + this.el.replaceWith(autoOrientedCanvas); + this.render(); + this.update(); + }, { + orientation: true, + // From CSS: + // maxWidth: 30em --> 420px + // maxHeight: 300px + maxWidth: 420, + maxHeight: 300, + }); }, events: { 'load': 'update', @@ -25,7 +36,11 @@ this.trigger('update'); }, render: function() { - this.$el.attr('src', this.dataUrl); + if (!this.source) { + return this; + } + + this.$el.attr('src', this.source); return this; } });