Skip to content

Instantly share code, notes, and snippets.

@tcelestino
Created April 30, 2013 17:29
Show Gist options
  • Save tcelestino/5490336 to your computer and use it in GitHub Desktop.
Save tcelestino/5490336 to your computer and use it in GitHub Desktop.
Add value customize input (metabox) when upload files on WordPress. This functions is based in solution posted on stackoverflow: http://stackoverflow.com/a/5671763/1156665
/*
save file upload customize input wordpress
@return void
*/
function saveFileUpload(button, input) {
var uploadID = '';
jQuery(button).click(function() {
uploadID = jQuery(this).prev('input');
formfield = jQuery(input).attr('name');
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
return false;
});
window.send_to_editor = function(html) {
fileurl = jQuery(html).attr('href');
uploadID.val(fileurl);
tb_remove();
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment