When I first began looking into this, File Gallery got me much closer to solving the problem. The only issue is that the plugin only displays the generic non-image icon when I upload a file.
Does anyone know of a pre-existing plugin that would either work alongside File Gallery or in place of it to achieve logos specific to a file type (say, I upload a .doc file then the plugin displays a MS Word logo).
Failing a pre-existing plugin, what would be a good starting point to attempt to craft my own hand-made solution?
Thanks in advance!
Note: This was originally posted in on the wordpress.org support forum here, but since it got no responses there, I thought I’d try my luck here.
WordPress has a native function
wp_mime_type_icon()
inwp-includes/post.php
that you can use.Basic example:
Look in
wp-includes/images/crystal/
for available file type icons:You can set up your own image directory and filter
'icon_dir'
for the local path and'icon_dir_uri'
for the URIs to let WordPress use your images.To change just singular files filter
'wp_mime_type_icon'
:I don’t think you will have luck getting it to work with another gallery plugin without altering that plugins code, but you can do this yourself rather easily by writing a plugin/function or using a template page.
What you can do is use
get_children
to grab thepost_mime_type
, in your case a simple example would be,Once you have the mime type you can use
wp_get_attachment_link
to create the link, unfortunately this functions$icon
parameter is a boolean so it does not allow you to add your own icon, you will have toecho
out an actual url to the icon you want to use.http://codex.wordpress.org/Function_Reference/get_children
http://codex.wordpress.org/Function_Reference/wp_get_attachment_link
http://tgrayimages.com/automate-file-attachments-on-your-wordpress-posts/