It is just a little syntax error in your window.send_to_editor
function:
imgurl = $( 'img', html ).attr( 'src' );
should be
imgurl = $( 'img', $( html ) ).attr( 'src' );
because your html
variable is neither a valid DOM nor a jQuery Element.
Additional Note:
If you want to use the Thickbox on multiple text fields, I’d recommend storing and creating your send_to_editor
function:
var image_field,
store_send_to_editor = null,
new_send_to_editor = null;
jQuery( function( $ ) {
store_send_to_editor = window.send_to_editor;
new_send_to_editor = function(html) {
imgurl = $( 'img', $( html ) ).attr( 'src' );
image_field.val( imgurl );
tb_remove();
window.send_to_editor = store_send_to_editor;
};
$( document ).on( 'click', 'input.select-img', function( evt ) {
image_field = $( this ).siblings( '.img' );
check_flag = 1;
tb_show( '', 'media-upload.php?type=image&TB_iframe=true' );
window.sent_to_editor = new_send_to_editor;
return false;
} );
} );