The Frosty
By: a guest | Mar 4th, 2010 | Syntax:
JavaScript | Size: 1.03 KB | Hits: 1,459 | Expires: Never
jQuery(document).ready(function() {
var formfield;
jQuery('#Image_button').click(function() {
jQuery('html').addClass('Image');
formfield = jQuery('#Image').attr('name');
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
return false;
});
/*
window.send_to_editor = function(html) {
if ( jQuery('html').hasClass('Image') ) {
imgurl = jQuery('img',html).attr('src');
jQuery('#Image').val(imgurl);
tb_remove();
jQuery('html').removeClass('Image');
}
}*/
// user inserts file into post. only run custom if user started process using the above process
// window.send_to_editor(html) is how wp would normally handle the received data
window.original_send_to_editor = window.send_to_editor;
window.send_to_editor = function(html){
if (formfield) {
fileurl = jQuery('img',html).attr('src');
jQuery('#Image').val(fileurl);
tb_remove();
jQuery('html').removeClass('Image');
} else {
window.original_send_to_editor(html);
}
};
});