Question

I'm using the Wordpress Thickbox to try and retrun the value of the images that a user wants to select (when they click 'Insert into Post'), but the Thickbox is not closing, just showing as any empty white box.

The field $('#office-image input#image') exists, and Firebug is not reporitng any errors.

I'm not sure why this is not working, so any help is appriciated. Thanks.

window.send_to_editor = function(html){

    var image_url = $('img', html).attr('src');

    $('#office-image input#image').val(image_url);
    tb_remove();

}
Was it helpful?

Solution

tb_show('', 'media-upload.php?type=image&TB_iframe=true');
window.original_send_to_editor = window.send_to_editor;
window.send_to_editor = function (html) {
    var fileInput = jQuery(fileInput_id);
    if (fileInput) {
        fileurl = jQuery('img', html).attr('src');
        jQuery(fileInput).val(fileurl);
        tb_remove();

    } else {
        window.original_send_to_editor(html);
    }
};

I am using above script for that and its working fine

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top