Change categories count to include media attachments

You’ve probably solved this, but for anyone else that needs this:

$wp_taxonomies['category']->update_count_callback = '_update_generic_term_count';

This is significant in the case of attachments. Because an attachment
is a type of post, the default _update_post_term_count() will be used.
However, this may be undesirable, because this will only count
attachments that are actually attached to another post (like when you
insert an image into a post). This means that attachments that you
simply upload to WordPress using the Media Library, but do not
actually attach to another post will not be counted. If your intention
behind associating a taxonomy with attachments was to leverage the
Media Library as a sort of Document Management solution, you are
probably more interested in the counts of unattached Media items, than
in those attached to posts. In this case, you should force the use of
_update_generic_term_count() by setting ‘_update_generic_term_count’ as the value for update_count_callback.

from WordPress Codex on register_taxonomy