This patch provide taxonomy_image_save function, this function allow, who want to interact with taxonomy image, to pass an image file like drupal file object or like a path string, a taxonomy id and doesn't care about file moving in directory specified trough taxonomy_image_path variable, duplicate name file, deletion of old taxonomy image file and db 'update'.
I've made modifications to path saved to DB according to path registered in taxonomy_image_path variable, but I'm thinking to revise them another time to avoid db modification on taxonomy_image_path variable.

CommentFileSizeAuthor
taxonomy_image.module.patch12.07 KBcoreykck

Comments

nancydru’s picture

Status: Patch (to be ported) » Needs review

Could you, please, provide a few paragraphs of documentation about this to be added to the handbook documentation.

coreykck’s picture

No more things to add except the function comment:

function taxonomy_image_save($tid, $file, $strict_image = FALSE)
Saving image in taxonomy_image_path and insert to DB
@return string file path or FALSE if error
@param int $tid taxonomy term id
@param object $file drupal file object or string source file path
@param boolean $strict_image if set to true, only image files are allowed.

Other changes are related to images path reported in db table, I think that writing all path in db isn't the best solution, so I've modified the DB insert and select, to permit use of the core part of the file path. I've made a little error in this part; I included the configuration path, I'll cut it in the future.

I changed path stored in cache to prevent storing of full image path.

I encourage all to use taxonomy_image_save , in this mode all developer that have to use taxonomy image module can ignore db structure and taxonomy image developers could change it without negative impact over other's work.
Good work
Corrado