Make WordPress Core

Changeset 29686


Ignore:
Timestamp:
09/03/2014 06:09:33 AM (10 years ago)
Author:
nacin
Message:

Media: Avoid repeated thumbnail resizing.

props avryl, wonderboymusic, azaozz.
fixes #27423.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/css/media-views.css

    r29632 r29686  
    25122512}
    25132513
    2514 .attachments[data-columns="1"] .attachment {
     2514.media-frame-content[data-columns="1"] .attachment {
    25152515    width: 100%;
    25162516}
    25172517
    2518 .attachments[data-columns="2"] .attachment {
     2518.media-frame-content[data-columns="2"] .attachment {
    25192519    width: 50%;
    25202520}
    25212521
    2522 .attachments[data-columns="3"] .attachment {
     2522.media-frame-content[data-columns="3"] .attachment {
    25232523    width: 33.3%;
    25242524}
    25252525
    2526 .attachments[data-columns="4"] .attachment {
     2526.media-frame-content[data-columns="4"] .attachment {
    25272527    width: 25%;
    25282528}
    25292529
    2530 .attachments[data-columns="5"] .attachment {
     2530.media-frame-content[data-columns="5"] .attachment {
    25312531    width: 20%;
    25322532}
    25332533
    2534 .attachments[data-columns="6"] .attachment {
     2534.media-frame-content[data-columns="6"] .attachment {
    25352535    width: 16.6%;
    25362536}
    25372537
    2538 .attachments[data-columns="7"] .attachment {
     2538.media-frame-content[data-columns="7"] .attachment {
    25392539    width: 14.2%;
    25402540}
    25412541
    2542 .attachments[data-columns="8"] .attachment {
     2542.media-frame-content[data-columns="8"] .attachment {
    25432543    width: 12.5%;
    25442544}
    25452545
    2546 .attachments[data-columns="9"] .attachment {
     2546.media-frame-content[data-columns="9"] .attachment {
    25472547    width: 11.1%;
    25482548}
    25492549
    2550 .attachments[data-columns="10"] .attachment {
     2550.media-frame-content[data-columns="10"] .attachment {
    25512551    width: 10%;
    25522552}
    25532553
    2554 .attachments[data-columns="11"] .attachment {
     2554.media-frame-content[data-columns="11"] .attachment {
    25552555    width: 9%;
    25562556}
    25572557
    2558 .attachments[data-columns="12"] .attachment {
     2558.media-frame-content[data-columns="12"] .attachment {
    25592559    width: 8.3%;
    25602560}
  • trunk/src/wp-includes/js/media-views.js

    r29680 r29686  
    52005200
    52015201            this._viewsByCid = {};
     5202            this.$window = $( window );
     5203            this.resizeEvent = 'resize.media-modal-columns';
    52025204
    52035205            this.collection.on( 'add', function( attachment ) {
     
    52315233
    52325234            if ( this.options.resize ) {
    5233                 $( window ).on( 'resize.media-modal-columns', this.setColumns );
     5235                this.on( 'ready', this.bindEvents );
    52345236                this.controller.on( 'open', this.setColumns );
    5235             }
    5236 
    5237             // Call this.setColumns() after this view has been rendered in the DOM so
    5238             // attachments get proper width applied.
    5239             _.defer( this.setColumns, this );
     5237
     5238                // Call this.setColumns() after this view has been rendered in the DOM so
     5239                // attachments get proper width applied.
     5240                _.defer( this.setColumns, this );
     5241            }
     5242        },
     5243
     5244        bindEvents: function() {
     5245            this.$window.off( this.resizeEvent ).on( this.resizeEvent, _.debounce( this.setColumns, 50 ) );
    52405246        },
    52415247
     
    52505256        arrowEvent: function( event ) {
    52515257            var attachments = this.$el.children( 'li' ),
    5252                 perRow = this.$el.data( 'columns' ),
     5258                perRow = this.columns,
    52535259                index = attachments.filter( ':focus' ).index(),
    52545260                row = ( index + 1 ) <= perRow ? 1 : Math.ceil( ( index + 1 ) / perRow );
     
    52935299        dispose: function() {
    52945300            this.collection.props.off( null, null, this );
    5295             $( window ).off( 'resize.media-modal-columns' );
     5301            if ( this.options.resize ) {
     5302                this.$window.off( this.resizeEvent );
     5303            }
    52965304
    52975305            /**
     
    53095317
    53105318                if ( ! prev || prev !== this.columns ) {
    5311                     this.$el.attr( 'data-columns', this.columns );
     5319                    this.$el.closest( '.media-frame-content' ).attr( 'data-columns', this.columns );
    53125320                }
    53135321            }
Note: See TracChangeset for help on using the changeset viewer.