wp-media-picker.js
function( attachment ) {
			var noChange = ( attachment && this._attachment && attachment.id === this._attachment.id ) || ( ! attachment && ! this._attachment );

			if ( ! attachment ) {
				this._resetContent();

				if ( noChange ) {
					return;
				}

				this.element.val( null );
				this.element.trigger( 'change' );

				if ( 'function' === typeof this.options.clear ) {
					this.options.clear.call( this );
				}

				$( document ).trigger( 'wpMediaPicker.updateField', [ null, this ] );
				return;
			}

			this._createContent( attachment );

			if ( noChange ) {
				return;
			}

			if ( 'url' === this.options.store ) {
				this.element.val( attachment.url );
			} else {
				this.element.val( attachment.id );
			}
			this.element.trigger( 'change' );

			if ( 'function' === typeof this.options.change ) {
				this.options.change.call( this );
			}

			$( document ).trigger( 'wpMediaPicker.updateField', [ attachment, this ] );
		}
function( attachment ) {
			var noChange = ( attachment && this._attachment && attachment.id === this._attachment.id ) || ( ! attachment && ! this._attachment );

			if ( ! attachment ) {
				this._resetContent();

				if ( noChange ) {
					return;
				}

				this.element.val( null );
				this.element.trigger( 'change' );

				if ( 'function' === typeof this.options.clear ) {
					this.options.clear.call( this );
				}

				$( document ).trigger( 'wpMediaPicker.updateField', [ null, this ] );
				return;
			}

			this._createContent( attachment );

			if ( noChange ) {
				return;
			}

			if ( 'url' === this.options.store ) {
				this.element.val( attachment.url );
			} else {
				this.element.val( attachment.id );
			}
			this.element.trigger( 'change' );

			if ( 'function' === typeof this.options.change ) {
				this.options.change.call( this );
			}

			$( document ).trigger( 'wpMediaPicker.updateField', [ attachment, this ] );
		}
function ( attachment ) { var noChange = ( attachment && this . _attachment && attachment . id === this . _attachment . id ) || ( ! attachment && ! this . _attachment ) ; if ( ! attachment ) { this . _resetContent ( ) ; if ( noChange ) { return ; } this . element . val ( null ) ; this . element . trigger ( 'change' ) ; if ( 'function' === typeof this . options . clear ) { this . options . clear . call ( this ) ; } $ ( document ) . trigger ( 'wpMediaPicker.updateField' , [ null , this ] ) ; return ; } this . _createContent ( attachment ) ; if ( noChange ) { return ; } if ( 'url' === this . options . store ) { this . element . val ( attachment . url ) ; } else { this . element . val ( attachment . id ) ; } this . element . trigger ( 'change' ) ; if ( 'function' === typeof this . options . change ) { this . options . change . call ( this ) ; } $ ( document ) . trigger ( 'wpMediaPicker.updateField' , [ attachment , this ] ) ; }
Sets the currently selected attachment.

If the attachment is different from the current attachment,
change events will be triggered.

@since 0.7.0

@param {object} attachment WordPress attachment data.

@returns {void}
Sets the currently selected attachment .