Created
April 30, 2013 17:29
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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