Skip to content

Commit

Permalink
Merge pull request TryGhost#1222 from mduvall/encoding-image-upload
Browse files Browse the repository at this point in the history
r# the commit.
  • Loading branch information
ErisDS committed Oct 24, 2013
2 parents 0ddd7e8 + 6dc3e05 commit 37359dc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
3 changes: 2 additions & 1 deletion core/client/models/uploadModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/*';
}
});

}());
}());
2 changes: 1 addition & 1 deletion core/client/tpl/modals/uploadImage.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<section class="js-drop-zone">
<img class="js-upload-target" src="{{options.src}}"{{#unless options.src}} style="display: none"{{/unless}} alt="logo">
<input data-url="upload" class="js-fileupload main" type="file" name="uploadimage">
<input data-url="upload" class="js-fileupload main" type="file" name="uploadimage" {{#if options.acceptEncoding}}accept="{{options.acceptEncoding}}"{{/if}}>
</section>
41 changes: 21 additions & 20 deletions core/client/views/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

self.model.save(data, {
success: self.saveSuccess,
error: self.saveError
}).then(function () {
self.saveSettings();
});
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();
});

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
Expand Down

0 comments on commit 37359dc

Please sign in to comment.