Media Library images missing in modal uploader

Published 10 Dec 2012 in PHP & MySQL, Plugins, Themes, WordPress by ZigPress

This is an interesting little WordPress problem, and I don’t think I’ve seen a solution posted elsewhere.

On a couple of projects recently, I found that, while creating a custom theme and custom plugins, the “Media Library” tab of the WordPress modal media uploader suddenly stopped showing the list of images. It still showed an image count but the images themselves were not displayed.

I deactivated all plugins and found that the problem disappeared. I then reactivated them one by one and found that it was my custom plugin that caused the problem. I heaved a sigh, commented out the content of all my plugin’s method functions, and then uncommented them line by line until I found the code that was responsible. I found that the culprit code was using the register_taxonomy() function to create a custom taxonomy called “type”. As soon as I renamed the custom taxonomy to something other than “type”, the problem disappeared.

However, I wasn’t convinced that this made sense, and I realised another thing: my call to register_taxonomy() was happening in my plugin’s class constructor, rather than inside an action hook. I renamed the custom taxonomy back to “type” (just to prove the point), put the call into the “init” action, and everything worked fine. However, I’ve now decided to avoid using the name “type” for custom content types and taxonomies, just in case it breaks something else that I haven’t noticed yet.

And if you’re thinking “but these solutions have nothing to do with the media library or modal uploader”, then you’re not alone! I’m chalking it up as one of WordPress’s little foibles. It has quite a few after all.

So, if you have this problem while developing a WordPress site, check two things:

1. If you are creating custom content types and taxonomies, make sure they are created within the “init” action.

2. If you are creating a custom taxonomy, I’d advise not calling it “type” to be on the safe side.

Please note that if you actually read the WordPress Codex documentation for the register_taxonomy() function in its entirety, you’ll find advice about both of these issues (using the function in an action, and avoiding reserved words). However, since when do most developers read more documentation than they think they can get away with? :-)


  1. On 19 Dec 2012 at 06:35, Truman Edwards said:

    Thank you for this post. It was a problem I used to get every now and then and it frustrated me to no end.

  2. On 03 Jan 2013 at 12:31, Terry said:

    Thanks for this explanation. I’m having the same problem and was looking for a solution. I’m going to try it and see if it works for me too.



  3. On 19 Feb 2013 at 10:42, Servernoob said:

    Thank you, that is exactly, what i needed!! You made my day ;)

    Regards from germany!

  4. On 29 Mar 2013 at 19:10, Ross IT said:

    Thankyou so much for this, was exactly what i was looking for!! i am bookmarking your website for future use :)

  5. On 20 Apr 2013 at 07:25, Radio Ads Production said:

    Awesome info. Thanks for sharing.

  6. On 15 May 2013 at 09:09, Nutcache – Free online time sheet tracking software said:

    Great info! I recently came across your blog and have been reading along. Nice post.

  7. On 28 May 2013 at 01:34, Stacey said:

    Great info! I can certainly see a huge future headache has been saved. Good point on commenting everything out and then adding back in one by one too.

Add a Comment

If you have used this form and would like a copy of the information held about you on this website, or would like the information deleted, please email [email protected].