My Old Question:
I made a Theme with rotating banner, common thing. So I want a way for users to select images. I think instead of implementing my own upload, I think its better to allow users to use the Media Library, how do I do that?
The New One
So far, I have something like below
functions.php
// init wordpress media upload stuff ...
if (is_admin() && isset($_GET['page']) && $_GET['page'] == 'elem_opts') {
wp_enqueue_style('thickbox');
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
wp_register_script('elem_adm_js', get_bloginfo('template_directory') . '/js/admin.js', array('jquery', 'media-upload', 'thickbox'));
wp_enqueue_script('elem_adm_js');
}
admin.js
jQuery(document).ready(function($) {
$('#elem_upload_logo').click(function() {
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
return false;
});
window.send_to_editor = function (html) {
imgurl = $('img', html).attr('src');
$('input[name=elem_opts[h_image]]').val(imgurl);
tb_remove();
}
});
The media library upload thickbox pops up, I can click select files, but when I try to upload them nothing happens. In Firebug I can see the following: