From 9350f67e28f72006e1cd3d60fd7b76c8a91d06d2 Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Tue, 20 Nov 2012 11:57:08 +0000 Subject: [PATCH] Media: Refresh the attachment display settings when the active attachment finishes uploading. fixes #22452, see #21390. git-svn-id: http://core.svn.wordpress.org/trunk@22710 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/media-views.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index fbec2e1dde..287caa3c3e 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -1531,9 +1531,8 @@ display: new media.view.Settings.AttachmentDisplay({ controller: this, model: display[ single.cid ], - sizes: single.get('sizes'), + attachment: single, priority: 160, - type: single.get('type'), userSettings: state.get('displayUserSettings') }).render() }, options ); @@ -3032,14 +3031,36 @@ template: media.template('attachment-display-settings'), initialize: function() { + var attachment = this.options.attachment; + _.defaults( this.options, { userSettings: false }); + media.view.Settings.prototype.initialize.apply( this, arguments ); this.model.on( 'change:link', this.updateCustomLink, this ); + + if ( attachment ) + attachment.on( 'change:uploading', this.render, this ); + }, + + dispose: function() { + var attachment = this.options.attachment; + if ( attachment ) + attachment.off( null, null, this ); + + media.view.Settings.prototype.dispose.apply( this, arguments ); }, render: function() { + var attachment = this.options.attachment; + if ( attachment ) { + _.extend( this.options, { + sizes: attachment.get('sizes'), + type: attachment.get('type') + }); + } + media.view.Settings.prototype.render.call( this ); this.updateCustomLink(); return this;