diff --git a/src/admin/components/edition/collection-edition-form.vue b/src/admin/components/edition/collection-edition-form.vue index 30fc1cd22..0281bd6e5 100644 --- a/src/admin/components/edition/collection-edition-form.vue +++ b/src/admin/components/edition/collection-edition-form.vue @@ -801,12 +801,14 @@ export default { frame_button: this.$i18n.get('label_select_file'), }, relatedPostId: this.collectionId, - onSave: (mediaId) => { - this.updateThumbnail({collectionId: this.collectionId, thumbnailId: mediaId}) - .then((res) => { - this.collection.thumbnail = res.thumbnail; + onSave: (media) => { + this.updateThumbnail({ + collectionId: this.collectionId, thumbnailId: media.id }) - .catch(error => this.$console.error(error)); + .then((res) => { + this.collection.thumbnail = res.thumbnail; + }) + .catch(error => this.$console.error(error)); } } ); diff --git a/src/admin/components/edition/item-edition-form.vue b/src/admin/components/edition/item-edition-form.vue index 23e7175ae..82d8544aa 100644 --- a/src/admin/components/edition/item-edition-form.vue +++ b/src/admin/components/edition/item-edition-form.vue @@ -1009,8 +1009,8 @@ export default { frame_title: this.$i18n.get('instruction_select_item_thumbnail'), }, relatedPostId: this.itemId, - onSave: (mediaId) => { - this.updateThumbnail({itemId: this.itemId, thumbnailId: mediaId}) + onSave: (media) => { + this.updateThumbnail({itemId: this.itemId, thumbnailId: media.id}) .then((res) => { this.item.thumbnail = res.thumbnail; }) diff --git a/src/admin/components/edition/term-edition-form.vue b/src/admin/components/edition/term-edition-form.vue index a616b12c9..3d26d34de 100644 --- a/src/admin/components/edition/term-edition-form.vue +++ b/src/admin/components/edition/term-edition-form.vue @@ -279,13 +279,15 @@ ); }, initializeMediaFrames() { - this.headerImageMediaFrame = new wpMediaFrames.headerImageControl( - 'my-header-image-media-frame', { + this.headerImageMediaFrame = new wpMediaFrames.thumbnailControl( + 'my-thumbnail-image-media-frame', { button_labels: { frame_title: this.$i18n.get('instruction_select_term_header_image'), + frame_button: this.$i18n.get('label_select_file') }, relatedPostId: this.editForm.id, onSave: (croppedImage) => { + this.editForm = Object.assign({}, this.editForm, { diff --git a/src/admin/js/wp-media-frames.js b/src/admin/js/wp-media-frames.js index e37fda428..f20a8e275 100644 --- a/src/admin/js/wp-media-frames.js +++ b/src/admin/js/wp-media-frames.js @@ -113,11 +113,11 @@ export default { id: this.params.relatedPostId } this.params.attachment = attachment; - this.params.onSave(attachment.id); + this.params.onSave(attachment); } }), - // CroppedImageControl, with presets for thumbnail dimensions + // CroppedImageControl, with presets for header dimensions headerImageControl: wp.customize.CroppedImageControl.extend({ initFrame: function() {