wp-media-picker.js
function getAttachment( val, valType, onFound, onNotFound ) {
		var requestData;

		if ( ! val ) {
			onNotFound();
			return;
		}

		if ( 'url' === valType ) {
			requestData = {
				action: 'get-attachment-by-url',
				url: val
			};
		} else {
			requestData = {
				action: 'get-attachment',
				id: parseInt( val, 10 )
			};
		}

		wp.media.ajax({
			type: 'POST',
			data: requestData,
			success: onFound,
			error: onNotFound
		});
	}
function getAttachment( val, valType, onFound, onNotFound ) {
		var requestData;

		if ( ! val ) {
			onNotFound();
			return;
		}

		if ( 'url' === valType ) {
			requestData = {
				action: 'get-attachment-by-url',
				url: val
			};
		} else {
			requestData = {
				action: 'get-attachment',
				id: parseInt( val, 10 )
			};
		}

		wp.media.ajax({
			type: 'POST',
			data: requestData,
			success: onFound,
			error: onNotFound
		});
	}
function getAttachment ( val , valType , onFound , onNotFound ) { var requestData ; if ( ! val ) { onNotFound ( ) ; return ; } if ( 'url' === valType ) { requestData = { action : 'get-attachment-by-url' , url : val } ; } else { requestData = { action : 'get-attachment' , id : parseInt ( val , 10 ) } ; } wp . media . ajax ( { type : 'POST' , data : requestData , success : onFound , error : onNotFound } ) ; }
Gets an attachment object via AJAX based on a given ID or URL.

@since 0.7.0

@private

@param {number|string} val        Attachment ID or URL.
@param {string}        valType    Whether 'val' was provided as 'id' or 'url'.
@param {function}      onFound    Callback to pass the found attachment to.
@param {function}      onNotFound Callback to run if no attachment was found.

@return {void}
Gets an attachment object via AJAX based on a given ID or URL .