You are here

function taxonomy_image_add in Taxonomy Image 6

Helper function for adding an image to a term

1 call to taxonomy_image_add()
taxonomy_image_taxonomy in ./taxonomy_image.module
Implementation of hook_taxonomy().

File

./taxonomy_image.module, line 690
taxonomy_image.module Simple module for providing an association between taxonomy terms and images. Written by Jeremy Andrews <jeremy@kerneltrap.org>, May 2004.

Code

function taxonomy_image_add($tid, $filename) {

  // @TODO: maybe we need to store also the FILE-ID from {files} table, better deletion and shared counts.
  // Delete old image before saving the new one.
  if (_taxonomy_image_exists($tid)) {
    taxonomy_image_delete($tid);
  }
  if (db_query("INSERT INTO {term_image} (tid, path) VALUES ('%d', '%s')", $tid, $filename)) {
    cache_clear_all("taxonomy_image:{$tid}", 'cache_tax_image');
    return TRUE;
  }
  else {
    return FALSE;
  }
}