The code below allows me to retrieve the image string, when Insert to Post has been pressed, but what would be the correct way to retrieve the ID of the image? So I can retrieve all information through wp_get_attachment_image_src?
jQuery(document).ready(function() {
var form_field;
var upload_field_ID = '';
jQuery( '.upload_image_button' ).click( function() {
jQuery( 'html').addClass( 'Image' );
upload_field_ID = jQuery(this).prev('input');
form_field = upload_field_ID.attr( 'name' );
tb_show( '', 'media-upload.php?type=image&TB_iframe=true' );
return false;
});
window.original_send_to_editor = window.send_to_editor;
window.send_to_editor = function( html ) {
if (form_field) {
var image_url = jQuery( 'img', html ).attr( 'src' );
upload_field_ID.val( image_url );
tb_remove();
jQuery( 'html').removeClass( 'Image' );
} else {
window.original_send_to_editor( html );
}
}
});
