Skip to content

Instantly share code, notes, and snippets.

@justinwhall
Created March 8, 2012 01:34
Show Gist options
  • Save justinwhall/1997876 to your computer and use it in GitHub Desktop.
Save justinwhall/1997876 to your computer and use it in GitHub Desktop.
jQuery: WordPress | Uploader for theme options page
jQuery(document).ready(function() {
jQuery('.st_upload_button').click(function() {
/* formfield = jQuery('#st_upload').attr('name'); */
targetfield = jQuery(this).prev('.upload-url');
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
return false;
});
window.send_to_editor = function(html) {
imgurl = jQuery('img',html).attr('src');
jQuery(targetfield).val(imgurl);
tb_remove();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment