Make WordPress Core

Ticket #24019: media.patch

File media.patch, 3.4 KB (added by dfcowell, 12 years ago)

Media File Patch

  • wp-includes/js/media-editor.js

     
    5959
    6060                                sizes = attachment.sizes;
    6161                                size = sizes && sizes[ props.size ] ? sizes[ props.size ] : attachment;
    62 
     62                                linkSize = props.linkUrl ? sizes[ props.linkFileSize ] || 'full' : props.linkUrl;
     63                               
    6364                                _.extend( props, _.pick( attachment, 'align', 'caption', 'alt' ), {
    6465                                        width:     size.width,
    6566                                        height:    size.height,
    6667                                        src:       size.url,
    67                                         captionId: 'attachment_' + attachment.id
     68                                        captionId: 'attachment_' + attachment.id,
     69                                        linkUrl:   linkSize.url
    6870                                });
    6971                        } else if ( 'video' === attachment.type || 'audio' === attachment.type ) {
    7072                                _.extend( props, _.pick( attachment, 'title', 'type', 'icon', 'mime' ) );
  • wp-includes/js/media-views.js

     
    39833983
    39843984                        media.view.Settings.prototype.initialize.apply( this, arguments );
    39853985                        this.model.on( 'change:link', this.updateLinkTo, this );
     3986                        this.model.on( 'change:linkFileSize', this.updateLinkTo, this );
    39863987
    39873988                        if ( attachment )
    39883989                                attachment.on( 'change:uploading', this.render, this );
     
    40134014                updateLinkTo: function() {
    40144015                        var linkTo = this.model.get('link'),
    40154016                                $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');
    40174020
    40184021                        if ( 'none' === linkTo || ( ! attachment && 'custom' !== linkTo ) ) {
    40194022                                $input.hide();
     
    40214024                        }
    40224025
    40234026                        if ( attachment ) {
     4027                                if ( sizes && 'file' === linkTo ) {
     4028                                        $filesize.show();
     4029                                } else {
     4030                                        $filesize.hide();
     4031                                }
     4032                       
    40244033                                if ( 'post' === linkTo ) {
    40254034                                        $input.val( attachment.get('link') );
    40264035                                } 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                                        }
    40284041                                } else if ( ! this.model.get('linkUrl') ) {
    40294042                                        $input.val('http://');
    40304043                                }
  • wp-includes/media-template.php

     
    302302                                        </option>
    303303                                </select>
    304304                        </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 ); ?> &ndash; {{ size.width }} &times; {{ size.height }}
     322                                                                        </option>
     323                                                        <# } #>
     324                                        <?php endforeach; ?>
     325                                </select>
     326                        <# } #>
    305327                        <input type="text" class="link-to-custom" data-setting="linkUrl" />
    306328                </div>
    307329