| 1 | Index: wp-includes/js/media-views.js |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/js/media-views.js (revision 22963) |
|---|
| 4 | +++ wp-includes/js/media-views.js (working copy) |
|---|
| 5 | @@ -3411,7 +3411,7 @@ |
|---|
| 6 | }); |
|---|
| 7 | |
|---|
| 8 | media.view.Settings.prototype.initialize.apply( this, arguments ); |
|---|
| 9 | - this.model.on( 'change:link', this.updateCustomLink, this ); |
|---|
| 10 | + this.model.on( 'change:link', this.updateLinkTo, this ); |
|---|
| 11 | |
|---|
| 12 | if ( attachment ) |
|---|
| 13 | attachment.on( 'change:uploading', this.render, this ); |
|---|
| 14 | @@ -3435,23 +3435,32 @@ |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | media.view.Settings.prototype.render.call( this ); |
|---|
| 18 | - this.updateCustomLink(); |
|---|
| 19 | + this.updateLinkTo(); |
|---|
| 20 | return this; |
|---|
| 21 | }, |
|---|
| 22 | |
|---|
| 23 | - updateCustomLink: function() { |
|---|
| 24 | - var isCustom = 'custom' === this.model.get('link'), |
|---|
| 25 | - $input = this.$('.link-to-custom'); |
|---|
| 26 | + updateLinkTo: function() { |
|---|
| 27 | + var linkTo = this.model.get('link'), |
|---|
| 28 | + $input = this.$('.link-to-custom'), |
|---|
| 29 | + attachment = this.options.attachment; |
|---|
| 30 | |
|---|
| 31 | - if ( ! isCustom ) { |
|---|
| 32 | + if ( 'none' === linkTo ) { |
|---|
| 33 | $input.hide(); |
|---|
| 34 | return; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | $input.show(); |
|---|
| 38 | - if ( ! this.model.get('linkUrl') ) |
|---|
| 39 | + |
|---|
| 40 | + if ( 'post' == linkTo ) { |
|---|
| 41 | + $input.val( attachment.get('link') ); |
|---|
| 42 | + } else if ( 'file' == linkTo ) { |
|---|
| 43 | + $input.val( attachment.get('url') ); |
|---|
| 44 | + } else if ( ! this.model.get('linkUrl') ) { |
|---|
| 45 | $input.val('http://'); |
|---|
| 46 | + } |
|---|
| 47 | |
|---|
| 48 | + $input.prop('readonly', 'custom' !== linkTo); |
|---|
| 49 | + |
|---|
| 50 | // If the input is visible, focus and select its contents. |
|---|
| 51 | if ( $input.is(':visible') ) |
|---|
| 52 | $input.focus()[0].select(); |
|---|