Index: wp-includes/js/media-editor.js
===================================================================
--- wp-includes/js/media-editor.js (revision 23946)
+++ wp-includes/js/media-editor.js (working copy)
@@ -59,12 +59,14 @@
sizes = attachment.sizes;
size = sizes && sizes[ props.size ] ? sizes[ props.size ] : attachment;
-
+ linkSize = props.linkUrl ? sizes[ props.linkFileSize ] || 'full' : props.linkUrl;
+
_.extend( props, _.pick( attachment, 'align', 'caption', 'alt' ), {
width: size.width,
height: size.height,
src: size.url,
- captionId: 'attachment_' + attachment.id
+ captionId: 'attachment_' + attachment.id,
+ linkUrl: linkSize.url
});
} else if ( 'video' === attachment.type || 'audio' === attachment.type ) {
_.extend( props, _.pick( attachment, 'title', 'type', 'icon', 'mime' ) );
Index: wp-includes/js/media-views.js
===================================================================
--- wp-includes/js/media-views.js (revision 23946)
+++ wp-includes/js/media-views.js (working copy)
@@ -3983,6 +3983,7 @@
media.view.Settings.prototype.initialize.apply( this, arguments );
this.model.on( 'change:link', this.updateLinkTo, this );
+ this.model.on( 'change:linkFileSize', this.updateLinkTo, this );
if ( attachment )
attachment.on( 'change:uploading', this.render, this );
@@ -4013,7 +4014,9 @@
updateLinkTo: function() {
var linkTo = this.model.get('link'),
$input = this.$('.link-to-custom'),
- attachment = this.options.attachment;
+ $filesize = this.$('.link-to-file-size'),
+ attachment = this.options.attachment,
+ sizes = attachment.get('sizes');
if ( 'none' === linkTo || ( ! attachment && 'custom' !== linkTo ) ) {
$input.hide();
@@ -4021,10 +4024,20 @@
}
if ( attachment ) {
+ if ( sizes && 'file' === linkTo ) {
+ $filesize.show();
+ } else {
+ $filesize.hide();
+ }
+
if ( 'post' === linkTo ) {
$input.val( attachment.get('link') );
} else if ( 'file' === linkTo ) {
- $input.val( attachment.get('url') );
+ if( sizes ) {
+ $input.val( sizes[$filesize.val()].url );
+ } else {
+ $input.val( attachment.get('url') );
+ }
} else if ( ! this.model.get('linkUrl') ) {
$input.val('http://');
}
Index: wp-includes/media-template.php
===================================================================
--- wp-includes/media-template.php (revision 23946)
+++ wp-includes/media-template.php (working copy)
@@ -302,6 +302,28 @@
+ <# if ( 'undefined' !== typeof data.sizes ) { #>
+
+ <# } #>