There are several tasks you need to perform when you choose to do with custom code. And I personally think they’re complicated tasks. Here is the list of what I can imagine.
- Hook to the category edit page to add a new form for upload image. This can be done with the hook
{$taxonomy}_add_form_fields
. - Handle the image upload. Depend on what you want the upload field to be, it can be a HTML
file
input or a button to open the Media Library popup. - If it’s just a
file
input, then you have to work with pure PHP to handle upload via$_FILES
. - If it uses Media Library, then you need to work with JS to trigger the popup.
As you’re developing a theme, it can take a lot of time working on that. Besides, it belongs to plugin territory.
So, I’d suggest using a plugin for that. Meta Box framework with MB Term Meta extension works great in this case.
Disclaimer: I’m the author of Meta Box.