Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

added custom fields for the media edit form so users can select a thumbnail for video. All that's working fine but how can i get the default video icon on this page and in the media library to use this thumb instead of the default video icon?

default is http://sandbox.modernactivity.co.uk/waspface_wp/wp-includes/images/crystal/video.png

update got part of the way but not sure how i grab a custom field in this situation...

function change_mime_icon($icon, $mime = null, $post){

    $thumb = get_post_meta($post->ID,'_videoThumb', true); // needs to be attachment id?

    if($thumb){ //  videoThumb

        $icon = str_replace(get_bloginfo('wpurl').'/wp-includes/images/crystal/', WP_CONTENT_URL . '/uploads/'.$thumb, $icon);
        return $icon;

    }else{
        //leave as is...
    }
}
share|improve this question

1 Answer 1

You can do this with a three easy steps:

  1. Create a directory in your theme that will hold all the new icons /themes/theme-name/images/icons/
  2. Copy all the images from /wp-includes/images/crystal/ to your new directory
  3. Hook into the wp_mime_type_icon filter in your functions.php file

Your filter would look like this:

function change_mime_icon($icon, $mime = null, $post_id = null){
    $icon = str_replace(get_bloginfo('wpurl').'/wp-includes/images/crystal/', WP_CONTENT_URL . '/themes/theme-name/images/icons/', $icon);
    return $icon;
}
add_filter('wp_mime_type_icon', 'change_mime_icon');

To verify this is working, open the media library and browse the media gallery. If you see PHP warnings or errors, somethings has gone awry. If you see the icons displayed, you now have control over the images as they are being pulled from your theme directory.

Be careful not to change the names of the image files as they are called specifically in the core.

share|improve this answer
    
cheers brian - i actually want to use an image specified in a custom field so they icon represents the video itself. Made some edits above. Mostly there with the code you posted... –  daniel Crabbe Sep 14 '11 at 15:55
    
Daniel, do you want the image to appear in the media uploader? Is this image a screenshot of the video itself? Where do you want them to input the video icon - media uploader or post? Sorry, just a bit foggy here. –  Brian Fegter Sep 14 '11 at 16:19
    
Hey Brian - in the admin (everywhere), instead of the default icon for video i want it to use the specified thumb of the video which is set manually in a custom field after upload. It would make it a lot easier for our clients to organise showreels in the admin. –  daniel Crabbe Sep 21 '11 at 11:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.