Support » Plugins and Hacks » Hacks » 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?


    <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.

    various scripts, functions.php

    function my_admin_scripts() {
    wp_register_script('my-upload', WP_PLUGIN_URL.'/my-script.js', array('jquery','media-upload','thickbox'));
    function my_admin_styles() {
    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(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');

Viewing 2 replies - 1 through 2 (of 2 total)
  • The featured image feature is designed for posts, if you’re using it with something that is not a post i don’t believe it will work as you’re expecting.

    NOTE: You can add a post ID inside the tb_show call, just make sure you have the TB_iframe parameter remain last(there’s a bug that ignores any parameters after the TB_ ones).


    tb_show('', 'media-upload.php?type=image&post_id=0&TB_iframe=true');

    Yeah I figured it was a bit of a long shot.

    Thanks Mark.

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.