Jean-Marc Amiaud

Archive for mars, 2011

Replace WordPress default media icon with preview image

by le 05 Mar 2011, catégorie Programmation, WordPress

Media library in WordPress display thumbnail of the pictures but only generic icon for all other type.
It’s possible to change generics icons (eg. by video preview image) with pair of filter :

[code lang= »csharp »]

add_filter(‘wp_mime_type_icon’, ‘my_plugin_video_icon’, 10, 3);
add_filter(‘icon_dir’, ‘wp_plugin_video_icon_dir’);

function my_plugin_video_icon($icon, $mime, $post_id)
                 // – Find your icon for the specified post
                 // – Save the repository of your icon as global
                global $_current_video_icon_dir;
                $_current_video_icon_dir =  dirname(ABSPATH . substr($new_icon, strpos($new_icon, "wp-content")));

                // – Return your icon path
                return $new_icon;

function my_plugin_video_icon_dir($dir)
        global $_current_video_icon_dir;

                $var = $_current_video_icon_dir;
                $_current_video_icon_dir = null;
                return $var;
        return $dir;


Leave a Comment :, , , , Lire la suite...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!