From ea70b92d9b18201758e11fdc25b09afc97b50055 Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Fri, 9 Feb 2018 15:23:58 -0500 Subject: [PATCH] Use `Canvas::toDataURL` to preserve `ImageView` logic This way, all the other code paths remain untouched in case we want to remove the auto-orient code once Chrome supports the `image-orientation` CSS property. See: - #998 - https://developer.mozilla.org/en-US/docs/Web/CSS/image-orientation --- js/views/attachment_view.js | 5 ++--- stylesheets/_conversation.scss | 5 +---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/js/views/attachment_view.js b/js/views/attachment_view.js index f7f8afb7a..506e831d9 100644 --- a/js/views/attachment_view.js +++ b/js/views/attachment_view.js @@ -17,9 +17,8 @@ tagName: 'img', initialize: function(objectUrl, contentType, blob) { loadImage(blob, autoOrientedCanvas => { - this.el.replaceWith(autoOrientedCanvas); + this.source = autoOrientedCanvas.toDataURL(); this.render(); - this.update(); }, { orientation: true, }); @@ -31,7 +30,7 @@ this.trigger('update'); }, render: function() { - if (!this.source) { + if (this.source == null) { return this; } diff --git a/stylesheets/_conversation.scss b/stylesheets/_conversation.scss index 200e63986..6a0c6976b 100644 --- a/stylesheets/_conversation.scss +++ b/stylesheets/_conversation.scss @@ -568,10 +568,7 @@ span.status { background-color: #ccc; } - img, - canvas, /* used for auto-oriented images from `loadImage` */ - audio, - video { + img, audio, video { max-width: 100%; max-height: 300px; }