WordPress.org

Ready to get started?Download WordPress

Forums

Custom Icons in Media Manager for Custom Mime Types (6 posts)

  1. Chellechan
    Member
    Posted 3 years ago #

    Hello WordPress friends!

    I've created a custom mime type through functions.php using this code:

    function custom_upload_mimes ( $existing_mimes=array() ) {
    $existing_mimes['vcf'] = 'application/vcard';
    return $existing_mimes;
    }
    add_filter('upload_mimes', 'custom_upload_mimes');
    
    function modify_post_mime_types($post_mime_types) {
    	$post_mime_types['application/vcard'] = array(__('Contact Card', 'vcf'), __('Manage Contact Card', 'vcf'), __ngettext_noop('Contact Card (%s)', 'Contact Cards (%s)', 'vcf'));
    	return $post_mime_types;
    }
    add_filter('post_mime_types', 'modify_post_mime_types');

    I can upload this type of file successfully, and there is a custom section for it in the media manager.

    Problem: media manager shows a grey default icon (wp-includes/images/crystal/default.png) for my new files. I would like to use an icon that is indicative of the file type. It seems that this was possible in past versions of WordPress, but I can't find a way to accomplish it now.

  2. toneburst
    Member
    Posted 3 years ago #

    I wonder if your found a fix for this? I'm trying to do exactly the same thing!

    a|x

  3. Chellechan
    Member
    Posted 3 years ago #

    You know, I never did find a solution and just left it at the default for that project; however, I just did a quick search and found this blog post that might have a solution for you (about 1/2 way down).

    http://www.designfox.co/tips-tricks/add-custom-file-extensions-to-wordpress/

    Good luck!

  4. toneburst
    Member
    Posted 3 years ago #

    Hi, thanks for getting back to me. It's a novelty for me to actually get a reply on here, so I'm very grateful. Dunno what I'm doing wrong, but nobody ever seems to reply to my posts here...

    Anyway, that looks like it'll do what I want. Maybe I also need to incorporate a method for checking if new icons have been installed following a WordPress update, and if so, copy the new ones to the replacement icon directory, so that the old icons won't get 'stuck'. Hmm.

    Thanks again,

    a|x

  5. toneburst
    Member
    Posted 2 years ago #

    Works a treat, thanks!

    a|x

  6. Chellechan
    Member
    Posted 2 years ago #

    Great!! Thanks for posting your result! Now, if I can just remember this solution next time the problem pops up for me...

Topic Closed

This topic has been closed to new replies.

About this Topic