From 5413cf0d2d44af6dfc6a9d7df6e7bc8e21757db1 Mon Sep 17 00:00:00 2001 From: Matt DuVall Date: Mon, 21 Oct 2013 22:32:25 -0700 Subject: [PATCH] Allow only images to be uploaded in the upload modal Fixes #1221 - This changes the accepted encodings on the files upload input field to be only "image/*" now - --- ghost/admin/models/uploadModal.js | 3 +- ghost/admin/tpl/modals/uploadImage.hbs | 2 +- ghost/admin/views/settings.js | 39 +++++++++++++------------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/ghost/admin/models/uploadModal.js b/ghost/admin/models/uploadModal.js index dadbba2a21..341f8c5130 100644 --- a/ghost/admin/models/uploadModal.js +++ b/ghost/admin/models/uploadModal.js @@ -31,7 +31,8 @@ this.options.key = options.key; this.options.src = options.src; this.options.confirm.accept = options.accept; + this.options.acceptEncoding = options.acceptEncoding || 'image/*'; } }); -}()); \ No newline at end of file +}()); diff --git a/ghost/admin/tpl/modals/uploadImage.hbs b/ghost/admin/tpl/modals/uploadImage.hbs index 61fa86477e..54ff7a5cd2 100644 --- a/ghost/admin/tpl/modals/uploadImage.hbs +++ b/ghost/admin/tpl/modals/uploadImage.hbs @@ -1,4 +1,4 @@
- +
diff --git a/ghost/admin/views/settings.js b/ghost/admin/views/settings.js index 4739816163..28706b311e 100644 --- a/ghost/admin/views/settings.js +++ b/ghost/admin/views/settings.js @@ -205,27 +205,28 @@ this.showUpload('cover', settings.cover); }, showUpload: function (key, src) { - var self = this, upload = new Ghost.Models.uploadModal({'key': key, 'src': src, 'id': this.id, 'accept': { - func: function () { // The function called on acceptance - var data = {}; - if (this.$('.js-upload-url').val()) { - data[key] = this.$('.js-upload-url').val(); - } else { - data[key] = this.$('.js-upload-target').attr('src'); - } + var self = this, + upload = new Ghost.Models.uploadModal({'key': key, 'src': src, 'id': this.id, 'accept': { + func: function () { // The function called on acceptance + var data = {}; + if (this.$('.js-upload-url').val()) { + data[key] = this.$('.js-upload-url').val(); + } else { + data[key] = this.$('.js-upload-target').attr('src'); + } - self.model.save(data, { - success: self.saveSuccess, - error: self.saveError - }).then(function () { - self.saveSettings(); - }); + self.model.save(data, { + success: self.saveSuccess, + error: self.saveError + }).then(function () { + self.saveSettings(); + }); - return true; - }, - buttonClass: "button-save right", - text: "Save" // The accept button text - }}); + return true; + }, + buttonClass: "button-save right", + text: "Save" // The accept button text + }}); this.addSubview(new Ghost.Views.Modal({ model: upload