Allows term header to be cropped on any ration.

This commit is contained in:
Mateus Machado Luna 2019-02-20 15:45:51 -03:00
parent dbb74f4f5d
commit 6f27a10e65
4 changed files with 15 additions and 11 deletions

View File

@ -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));
}
}
);

View File

@ -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;
})

View File

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

View File

@ -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() {