I have created a metabox to upload images. Whenever I click on the "Select Image" button the Image Uploader Box successfully pops up but when I select an image and click the "Insert" button the image URL doesn't get inserted in the text field. Please tell me what to do so that whenever I insert an image the image URL gets inserted into the correct field.
var image_field;
jQuery( function( $ ) {
$( 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.send_to_editor = function( html ) {
imgurl = $( 'img', html ).attr( 'src' );
image_field.val( imgurl );
tb_remove();
}
return false;
} );
} );