From 1597e40a8abb1e33e65584d106be9096a9a65fc3 Mon Sep 17 00:00:00 2001 From: Robert Barrow Date: Mon, 23 Sep 2019 22:16:41 +0100 Subject: [PATCH] FEATURE: added image preview for image uploads --- .../wizard/components/wizard-field-upload.js.es6 | 7 +++++++ .../wizard/templates/components/wizard-field-upload.hbs | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/assets/javascripts/wizard/components/wizard-field-upload.js.es6 b/assets/javascripts/wizard/components/wizard-field-upload.js.es6 index f7f82faf..2425fd0a 100644 --- a/assets/javascripts/wizard/components/wizard-field-upload.js.es6 +++ b/assets/javascripts/wizard/components/wizard-field-upload.js.es6 @@ -4,6 +4,7 @@ import { getToken } from "wizard/lib/ajax"; export default Ember.Component.extend({ classNames: ["wizard-field-upload"], uploading: false, + isImage: false, didInsertElement() { this._super(); @@ -30,6 +31,12 @@ export default Ember.Component.extend({ "field.value": response.result, "uploading": false }); + console.log (response.result); + if (['jpg','jpeg','png','gif'].includes(response.result.extension)) { + this.setProperties({ + "isImage": true + }) + } }); $upload.on("fileuploadfail", (e, response) => { diff --git a/assets/javascripts/wizard/templates/components/wizard-field-upload.hbs b/assets/javascripts/wizard/templates/components/wizard-field-upload.hbs index 0e24849a..10e6b0dd 100644 --- a/assets/javascripts/wizard/templates/components/wizard-field-upload.hbs +++ b/assets/javascripts/wizard/templates/components/wizard-field-upload.hbs @@ -11,6 +11,10 @@ {{#if field.value}} - {{field.value.original_filename}} + {{#unless isImage}} + {{field.value.original_filename}} + {{else}} + + {{/unless}} {{/if}}