Implementing "use as featured image" functionality in alternate uploader
-
I have a script that allows me to use the functionality of the wordpress media uploader in my options page, however it doesn’t have the option of the “use as featured image” in the media uploader. Obviously having it would make life easier as you can resize the images with the post_thumbnail() function.
Here’s the script, any ideas on how I can add that functionality?
button
<tr valign="top"> <th scope="row">Upload Image</th> <td><label for="upload_image"> <input id="upload_image" type="text" size="36" name="upload_image" value="" /> <input id="upload_image_button" type="button" value="Upload Image" /> <br />Enter an URL or upload an image for the banner. </label></td> </tr>
various scripts, functions.php
function my_admin_scripts() { wp_enqueue_script('media-upload'); wp_enqueue_script('thickbox'); wp_register_script('my-upload', WP_PLUGIN_URL.'/my-script.js', array('jquery','media-upload','thickbox')); wp_enqueue_script('my-upload'); } function my_admin_styles() { wp_enqueue_style('thickbox'); } if (isset($_GET['page']) && $_GET['page'] == 'my_plugin_page') { add_action('admin_print_scripts', 'my_admin_scripts'); add_action('admin_print_styles', 'my_admin_styles'); }
Jquery
jQuery(document).ready(function() { jQuery('#upload_image_button').click(function() { formfield = jQuery('#upload_image').attr('name'); 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('#upload_image').val(imgurl); tb_remove(); } });
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Implementing "use as featured image" functionality in alternate uploader’ is closed to new replies.