How to “plug into” the Media Library (allow users to select images from Media li
-
I am trying to plug into the WordPress media library to allow users to select images & upload into it for use as the logo in a theme. I think its common but how can I acheive it?
I asked in WordPress StackExchange. So far, I have
// 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'); }
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(); } });
It shows the thickbox/media library upload box but there are JS errors …
invalid label
https://elements/wp-admin/media-upload.php?type=image&
Line 49post_id is not defined
https://elements/wp-admin/load-scripts.php?c=0&load=jquery,utils,swfupload-all,swfupload-handlers,json2&ver=2af6dbb1e89d69a2363895fac893188d
Line 178
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to “plug into” the Media Library (allow users to select images from Media li’ is closed to new replies.