Make WordPress Core

Ticket #21785: 21785.suggested-dimensions.5.diff

File 21785.suggested-dimensions.5.diff, 4.3 KB (added by nacin, 11 years ago)
  • wp-admin/js/customize-controls.js

     
    419419                 * @param {event} event
    420420                 */
    421421                openMedia: function(event) {
    422                         var suggestedWidth, suggestedHeight,
    423                                 l10n = _wpMediaViewsL10n;
     422                        var l10n = _wpMediaViewsL10n;
    424423
    425424                        event.preventDefault();
    426425
    427                         suggestedWidth = l10n.suggestedWidth.replace('%d', _wpCustomizeHeader.data.width);
    428                         suggestedHeight = l10n.suggestedHeight.replace('%d', _wpCustomizeHeader.data.height);
    429 
    430                         /* '<span class="suggested-dimensions">' + suggestedWidth + ' ' + suggestedHeight + '</span>' */
    431 
    432426                        this.frame = wp.media({
    433427                                title: l10n.chooseImage,
    434428                                library: {
     
    439433                                        close: false
    440434                                },
    441435                                multiple: false,
    442                                 imgSelectOptions: this.calculateImageSelectOptions
     436                                crop: {
     437                                        suggestedWidth: _wpCustomizeHeader.data.width,
     438                                        suggestedHeight: _wpCustomizeHeader.data.height,
     439                                        imgSelectOptions: this.calculateImageSelectOptions
     440                                }
    443441                        });
    444442
    445443                        this.frame.states.add([new wp.media.controller.Cropper()]);
  • wp-includes/css/media-views.css

     
    929929        line-height: 18px;
    930930        font-size: 13px;
    931931        color: #666;
     932        margin-right: 0.5em;
    932933}
    933934
    934935/**
  • wp-includes/js/media-views.js

     
    33123312                                }) );
    33133313                        }
    33143314                },
     3315
     3316                prepare: function() {
     3317                        var cropOptions = this.controller.options.crop;
     3318                        if ( cropOptions ) {
     3319                                return {
     3320                                        suggestedWidth: cropOptions.suggestedWidth,
     3321                                        suggestedHeight: cropOptions.suggestedHeight
     3322                                }
     3323                        }
     3324                },
    33153325                /**
    33163326                 * @returns {wp.media.view.UploaderInline} Returns itself to allow chaining
    33173327                 */
     
    51525162                },
    51535163
    51545164                createToolbar: function() {
    5155                         var filters, FiltersConstructor;
     5165                        var filters, FiltersConstructor,
     5166                                frameOptions = this.controller.options;
    51565167
    51575168                        /**
    51585169                         * @member {wp.media.view.Toolbar}
     
    51965207                                        priority: -40
    51975208                                }) );
    51985209                        }
     5210
     5211                        if ( frameOptions.crop ) {
     5212                                this.toolbar.set( 'suggestedDimensions', new media.View({
     5213                                        el: $( '<div class="instructions">' + l10n.suggestedDimensions + frameOptions.crop.suggestedWidth + ' &times; ' + frameOptions.crop.suggestedHeight + '</div>' )[0],
     5214                                        priority: -40
     5215                                }) );
     5216                        }
    51995217                },
    52005218
    52015219                updateContent: function() {
     
    62286246                        };
    62296247                },
    62306248                onImageLoad: function() {
    6231                         var imgOptions = this.controller.frame.options.imgSelectOptions;
     6249                        var imgOptions = this.controller.frame.options.crop.imgSelectOptions;
    62326250                        if (typeof imgOptions === 'function') {
    62336251                                imgOptions = imgOptions(this.options.attachment, this.controller);
    62346252                        }
  • wp-includes/media-template.php

     
    205205                                        printf( __( 'Maximum upload file size: %d%s.' ), esc_html($upload_size_unit), esc_html($byte_sizes[$u]) );
    206206                                ?></p>
    207207
     208                                <# if ( data.suggestedWidth && data.suggestedHeight ) { #>
     209                                        <p class="suggested-dimensions">
     210                                                <?php _e( 'Suggested image dimensions:' ); ?> {{{data.suggestedWidth}}} &times; {{{data.suggestedHeight}}}
     211                                        </p>
     212                                <# } #>
     213
    208214                                <?php
    209215                                /** This action is documented in wp-admin/includes/media.php */
    210216                                do_action( 'post-upload-ui' ); ?>
  • wp-includes/media.php

     
    25272527                'cropImage' => __( 'Crop Image' ),
    25282528                'cropYourImage' => __( 'Crop your image' ),
    25292529                'cropping' => __( 'Cropping&hellip;' ),
    2530                 'suggestedWidth' => __( 'Suggested width is %d pixels.' ),
    2531                 'suggestedHeight' => __( 'Suggested height is %d pixels.' ),
     2530                'suggestedDimensions' => __( 'Suggested image dimensions:' ),
    25322531                'cropError' => __( 'There has been an error cropping your image.' ),
    25332532
    25342533                // Edit Audio