This is just a half answer, but I wanted to share my findings.
When adding a new term via the Add Term screen /wp-admin/edit-tags.php?taxonomy=work_type&post_type=work
, AJAX is being used and it is not handling the $_FILES
array, so it is empty.
If you disable JS in your browser temporarily, then reload the page, add a new tag along with an image, then you can see that $_FILES
is now populated when debugging.
The AJAX is being handled using \wp-admin\js\tags.js
. Looking further in here, we can see that the $_FILES array is not being sent over with $.post(ajaxurl, $('#addtag').serialize(), function(r)
.
I’m not sure of the best way to get around this. One way would be to unwire WP’s AJAX handler, then create your own using the original handler as a starting point, but this is really not ideal.
While researching, I came across the Taxonomy Images plugin, which takes a different approach, by adding a UI next to each added term that allows you to upload an image.