Make WordPress Core

Changeset 28031


Ignore:
Timestamp:
04/08/2014 01:56:42 AM (13 years ago)
Author:
nacin
Message:

Header Images: Add suggested dimensions to the media workflow.

This updates [28030] to the latest patch.

props gcorne.
see #21785.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-controls.js

    r28030 r28031  
    425425
    426426                        this.frame = wp.media({
    427                                 title: l10n.chooseImage,
    428                                 library: {
    429                                         type: 'image'
    430                                 },
    431427                                button: {
    432428                                        text: l10n.selectAndCrop,
    433429                                        close: false
    434430                                },
    435                                 multiple: false,
    436                                 crop: {
    437                                         suggestedWidth: _wpCustomizeHeader.data.width,
    438                                         suggestedHeight: _wpCustomizeHeader.data.height,
    439                                         imgSelectOptions: this.calculateImageSelectOptions
    440                                 }
    441                         });
    442 
    443                         this.frame.states.add([new wp.media.controller.Cropper()]);
     431                                states: [
     432                                        new wp.media.controller.Library({
     433                                                title:     l10n.chooseImage,
     434                                                library:   wp.media.query({ type: 'image' }),
     435                                                multiple:  false,
     436                                                priority:  20,
     437                                                suggestedWidth: _wpCustomizeHeader.data.width,
     438                                                suggestedHeight: _wpCustomizeHeader.data.height
     439                                        }),
     440                                        new wp.media.controller.Cropper({
     441                                                imgSelectOptions: this.calculateImageSelectOptions
     442                                        })
     443                                ]
     444                        });
    444445
    445446                        this.frame.on('select', this.onSelect, this);
  • trunk/src/wp-includes/js/media-views.js

    r28030 r28031  
    18431843                                display:    state.get('displaySettings'),
    18441844                                dragInfo:   state.get('dragInfo'),
     1845
     1846                                suggestedWidth:  state.get('suggestedWidth'),
     1847                                suggestedHeight: state.get('suggestedHeight'),
    18451848
    18461849                                AttachmentView: state.get('AttachmentView')
    … …  
    33153318
    33163319                prepare: function() {
    3317                         var cropOptions = this.controller.options.crop;
    3318                         if ( cropOptions ) {
     3320                        var suggestedWidth = this.controller.state().get('suggestedWidth'),
     3321                                suggestedHeight = this.controller.state().get('suggestedHeight');
     3322
     3323                        if ( suggestedWidth && suggestedHeight ) {
    33193324                                return {
    3320                                         suggestedWidth: cropOptions.suggestedWidth,
    3321                                         suggestedHeight: cropOptions.suggestedHeight
    3322                                 }
     3325                                        suggestedWidth: suggestedWidth,
     3326                                        suggestedHeight: suggestedHeight
     3327                                };
    33233328                        }
    33243329                },
    … …  
    51655170
    51665171                createToolbar: function() {
    5167                         var filters, FiltersConstructor,
    5168                                 frameOptions = this.controller.options;
     5172                        var filters, FiltersConstructor;
    51695173
    51705174                        /**
    … …  
    52115215                        }
    52125216
    5213                         if ( frameOptions.crop ) {
     5217                        if ( this.options.suggestedWidth && this.options.suggestedHeight ) {
    52145218                                this.toolbar.set( 'suggestedDimensions', new media.View({
    5215                                         el: $( '<div class="instructions">' + l10n.suggestedDimensions + ' ' + frameOptions.crop.suggestedWidth + ' &times; ' + frameOptions.crop.suggestedHeight + '</div>' )[0],
     5219                                        el: $( '<div class="instructions">' + l10n.suggestedDimensions + ' ' + this.options.suggestedWidth + ' &times; ' + this.options.suggestedHeight + '</div>' )[0],
    52165220                                        priority: -40
    52175221                                }) );
    … …  
    62496253                },
    62506254                onImageLoad: function() {
    6251                         var imgOptions = this.controller.frame.options.crop.imgSelectOptions;
     6255                        var imgOptions = this.controller.get('imgSelectOptions');
    62526256                        if (typeof imgOptions === 'function') {
    62536257                                imgOptions = imgOptions(this.options.attachment, this.controller);
Note: See TracChangeset for help on using the changeset viewer.