Merge pull request #1222 from mduvall/encoding-image-upload

r# the commit.
This commit is contained in:
Hannah Wolfe 2013-10-24 14:37:23 +01:00
commit 37359dc7d6
3 changed files with 23 additions and 21 deletions

View File

@ -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/*';
}
});
}());
}());

View File

@ -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>

View File

@ -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