Ticket #24019: media.patch
File media.patch, 3.4 KB (added by , 12 years ago) |
---|
-
wp-includes/js/media-editor.js
59 59 60 60 sizes = attachment.sizes; 61 61 size = sizes && sizes[ props.size ] ? sizes[ props.size ] : attachment; 62 62 linkSize = props.linkUrl ? sizes[ props.linkFileSize ] || 'full' : props.linkUrl; 63 63 64 _.extend( props, _.pick( attachment, 'align', 'caption', 'alt' ), { 64 65 width: size.width, 65 66 height: size.height, 66 67 src: size.url, 67 captionId: 'attachment_' + attachment.id 68 captionId: 'attachment_' + attachment.id, 69 linkUrl: linkSize.url 68 70 }); 69 71 } else if ( 'video' === attachment.type || 'audio' === attachment.type ) { 70 72 _.extend( props, _.pick( attachment, 'title', 'type', 'icon', 'mime' ) ); -
wp-includes/js/media-views.js
3983 3983 3984 3984 media.view.Settings.prototype.initialize.apply( this, arguments ); 3985 3985 this.model.on( 'change:link', this.updateLinkTo, this ); 3986 this.model.on( 'change:linkFileSize', this.updateLinkTo, this ); 3986 3987 3987 3988 if ( attachment ) 3988 3989 attachment.on( 'change:uploading', this.render, this ); … … 4013 4014 updateLinkTo: function() { 4014 4015 var linkTo = this.model.get('link'), 4015 4016 $input = this.$('.link-to-custom'), 4016 attachment = this.options.attachment; 4017 $filesize = this.$('.link-to-file-size'), 4018 attachment = this.options.attachment, 4019 sizes = attachment.get('sizes'); 4017 4020 4018 4021 if ( 'none' === linkTo || ( ! attachment && 'custom' !== linkTo ) ) { 4019 4022 $input.hide(); … … 4021 4024 } 4022 4025 4023 4026 if ( attachment ) { 4027 if ( sizes && 'file' === linkTo ) { 4028 $filesize.show(); 4029 } else { 4030 $filesize.hide(); 4031 } 4032 4024 4033 if ( 'post' === linkTo ) { 4025 4034 $input.val( attachment.get('link') ); 4026 4035 } else if ( 'file' === linkTo ) { 4027 $input.val( attachment.get('url') ); 4036 if( sizes ) { 4037 $input.val( sizes[$filesize.val()].url ); 4038 } else { 4039 $input.val( attachment.get('url') ); 4040 } 4028 4041 } else if ( ! this.model.get('linkUrl') ) { 4029 4042 $input.val('http://'); 4030 4043 } -
wp-includes/media-template.php
302 302 </option> 303 303 </select> 304 304 </label> 305 <# if ( 'undefined' !== typeof data.sizes ) { #> 306 <select class="link-to-file-size" data-setting="linkFileSize"> 307 <?php 308 309 $sizes = apply_filters( 'image_size_names_choose', array( 310 'thumbnail' => __('Thumbnail'), 311 'medium' => __('Medium'), 312 'large' => __('Large'), 313 'full' => __('Full Size'), 314 ) ); 315 316 foreach ( $sizes as $value => $name ) : ?> 317 <# 318 var size = data.sizes['<?php echo esc_js( $value ); ?>']; 319 if ( size ) { #> 320 <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, 'full' ); ?>> 321 <?php echo esc_html( $name ); ?> – {{ size.width }} × {{ size.height }} 322 </option> 323 <# } #> 324 <?php endforeach; ?> 325 </select> 326 <# } #> 305 327 <input type="text" class="link-to-custom" data-setting="linkUrl" /> 306 328 </div> 307 329