Changeset 22558
- Timestamp:
- 11/13/2012 03:33:41 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/media-views.js
r22552 r22558 543 543 }, 544 544 545 initialize: function() { 546 this.on( 'change:url', this.scan, this ); 545 // The amount of time used when debouncing the scan. 546 sensitivity: 200, 547 548 initialize: function() { 549 this.debouncedScan = _.debounce( _.bind( this.scan, this ), this.sensitivity ); 550 this.on( 'change:url', this.debouncedScan, this ); 551 this.on( 'scan', this.scanImage, this ); 547 552 media.controller.State.prototype.initialize.apply( this, arguments ); 548 553 }, … … 551 556 var attributes = { type: 'link' }; 552 557 553 if ( /(?:jpe?g|png|gif)$/i.test( this.get('url') ) )554 attributes.type = 'image';555 556 558 this.trigger( 'scan', attributes ); 557 559 this.set( attributes ); 560 }, 561 562 scanImage: function( attributes ) { 563 var frame = this.frame, 564 state = this, 565 url = this.get('url'), 566 image = new Image(); 567 568 image.onload = function() { 569 if ( state === frame.state() && url === state.get('url') ) 570 state.set( 'type', 'image' ); 571 }; 572 573 image.src = url; 558 574 }, 559 575
Note: See TracChangeset
for help on using the changeset viewer.