mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Merge pull request #5897 from kevinansfield/fix-cover-post
Fix empty image when navigating to new editor from an editor with image
This commit is contained in:
commit
b2ada638c5
1 changed files with 25 additions and 0 deletions
|
@ -52,6 +52,31 @@ export default Ember.Component.extend({
|
|||
this.removeListeners();
|
||||
},
|
||||
|
||||
// NOTE: because the uploader is sometimes in the same place in the DOM
|
||||
// between transitions Glimmer will re-use the existing elements including
|
||||
// those that arealready decorated by jQuery. The following works around
|
||||
// situations where the image is changed without a full teardown/rebuild
|
||||
didReceiveAttrs: function (attrs) {
|
||||
var oldValue = attrs.oldAttrs && Ember.get(attrs.oldAttrs, 'image.value'),
|
||||
newValue = attrs.newAttrs && Ember.get(attrs.newAttrs, 'image.value'),
|
||||
self = this;
|
||||
|
||||
// always reset when we receive a blank image
|
||||
// - handles navigating to populated image from blank image
|
||||
if (Ember.isEmpty(newValue) && !Ember.isEmpty(oldValue)) {
|
||||
self.$()[0].uploaderUi.reset();
|
||||
}
|
||||
|
||||
// re-init if we receive a new image but the uploader is blank
|
||||
// - handles back button navigating from blank image to populated image
|
||||
if (!Ember.isEmpty(newValue) && this.$()) {
|
||||
if (this.$('.js-upload-target').attr('src') === '') {
|
||||
this.$()[0].uploaderUi.reset();
|
||||
this.$()[0].uploaderUi.initWithImage();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
initUploader: function () {
|
||||
var ref,
|
||||
|
|
Loading…
Add table
Reference in a new issue