From 4e9b815ba234640fc865b32dcc3eccddd91e4da5 Mon Sep 17 00:00:00 2001 From: "Kevin P. Kucharczyk" Date: Sat, 16 Jan 2016 21:54:02 +0100 Subject: [PATCH] Clear images in gh-uploader when navigating between items closes #6198 - clear img src in gh-uploader when navigating to item with image - always reset uploader component when new image is not empty --- ghost/admin/app/components/gh-uploader.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ghost/admin/app/components/gh-uploader.js b/ghost/admin/app/components/gh-uploader.js index 3fd24806a4..977feef836 100644 --- a/ghost/admin/app/components/gh-uploader.js +++ b/ghost/admin/app/components/gh-uploader.js @@ -36,13 +36,14 @@ export default Component.extend({ this.$()[0].uploaderUi.reset(); } - // re-init if we receive a new image but the uploader is blank + // re-init if we receive a new image // - handles back button navigating from blank image to populated image + // - handles navigating between populated images + if (!isEmpty(newValue) && this.$()) { - if (this.$('.js-upload-target').attr('src') === '') { - this.$()[0].uploaderUi.reset(); - this.$()[0].uploaderUi.initWithImage(); - } + this.$('.js-upload-target').attr('src', ''); + this.$()[0].uploaderUi.reset(); + this.$()[0].uploaderUi.initWithImage(); } },