Categories images plugin modified to save image ID

I very quickly (and badly) hacked up Zahlan’s excellent Categories Images plugin to save image IDs rather than the absolute URL to the image file. This means we can use WordPress’ image resizing as well as its other image meta tools.

Download the categories-images plugin (zip)

Update (10 Oct 12): The first upload had a bit of code left in from my own use of the plugin that limited it to a certain taxonomy. I’ve removed it now so the plugin works on all taxonomies as it should.

The key points are:

  • z_edit_taxonomy_field() and z_add_taxonomy_field()  are modified to have a separate button to upload the image rather than clicking the text box. It means the user can manually type the ID if they wish.
  • z_script() grabs the image ID from thickbox instead of the URL. Because thickbox returns an img tag with the image, the only way to get the ID is to chop it out of the class.
  • z_save_taxonomy_image() validates the image ID before saving in case the user types an ID in the text box.

3 replies on “Categories images plugin modified to save image ID”

Thanks for enhancing my plugin 🙂 but let me explain something, the reason I use the full image url to not force the user to host the image at his blog, he can use any url from anywhere, also I’m using it to let him easily can use any re-sizing image tools like timthumb.
I had also check the code, it will only work in case you have a taxonomy called ‘package_cat’ because you had disabled my foreach 🙂 so by default the plugin won’t work, I think you should test it on a new wordpress installation. Thanks again 🙂

Thanks for letting me know! I’ve updated it now. I personally prefer to use WordPress’ built in functions for images but I can see why you did it that way 🙂

hi i have installed this plugin it working properly in default template but in a wp template which i have created its not working in it plz help me its urgent

Comments are closed.