Index: taxonomy_image.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/taxonomy_image/taxonomy_image.module,v
retrieving revision 1.12.4.1
diff -r1.12.4.1 taxonomy_image.module
30,33c30,31
<       if ($image[$tid] = db_fetch_object(db_query('SELECT i.path, d.name FROM {term_image} i INNER JOIN {term_data} d WHERE i.tid = d.tid AND i.tid = %d', $tid))) {
<         $image[$tid]->url = file_create_url($image[$tid]->path);
<       }
<       else if (variable_get('taxonomy_image_recursive', 0)) {
---
>       $image[$tid] = db_fetch_object(db_query('SELECT i.path, d.name FROM {term_image} i INNER JOIN {term_data} d WHERE i.tid = d.tid AND i.tid = %d', $tid));
>       if (!$image && variable_get('taxonomy_image_recursive', 0)) {
45c43
<             $image[$tid]->url = file_create_url($image[$tid]->path);
---
>             $image[$tid]->path;
52c50,54
<     if ($image[$tid]->url) {
---
>     
>     // Do we have an image?
>     if ($image[$tid]->path) {
>       // Get the URL for it
>       $image[$tid]->url = file_create_url($image[$tid]->path);
54c56,57
<         list($image[$tid]->width, $image[$tid]->height) = getimagesize($image[$tid]->path);
---
>         // get the image size
>         list($image[$tid]->width, $image[$tid]->height) = getimagesize(file_directory_path() .'/'. $image[$tid]->path);
113c116
<       return t('The taxonomy_image module allows site administrators to associate images with category terms.  Once defined, this association allows Drupal themes to display images with site content.  For example, this module might be used to display a penguin with content about Linux, and a cheeseburger with content about junk food.  To upload a new image for a specific term, click "upload image" next to the term.  To modify or delete and existing image, click "edit image".  To learn more about how to create vocabularies and terms, review the <a href="%taxonomy-help">taxonomy help page</a>.', array('%taxonomy-help' => url('admin/help/taxonomy')));
---
>       return t('The taxonomy_image module allows site administrators to associate images with category terms.  Once defined, this association allows Drupal themes to display images with site content.  For example, this module might be used to display a penguin with content about Linux, and a cheeseburger with content about junk food.  To upload a new image for a specific term, click "upload image" next to the term.  To modify or delete and existing image, click "edit image".  To learn more about how to create vocabularies and terms, review the <a href="!taxonomy-help">taxonomy help page</a>.', array('!taxonomy-help' => url('admin/help/taxonomy')));
401,406c404,410
<   $edit['tid'] = $tid;
<   $fields = array('tid', 'path');
<   if ($file = file_save_upload('path', file_create_path(variable_get('taxonomy_image_path', 'category_pictures')))) {
<     $edit['path'] = $file->filepath;
< 
<     if ($old_image = db_fetch_object(db_query('SELECT tid FROM {term_image} WHERE tid = %d', $edit['tid']))) {
---
>   // Where should our images be?
>   $directory = file_create_path(variable_get('taxonomy_image_path', 'category_pictures'));
>   
>   // Does this dir exist? If not, make it
>   file_check_directory($directory, true);
>   if ($file = file_save_upload('path', $directory)) {
>     if ($old_image = db_fetch_object(db_query('SELECT tid FROM {term_image} WHERE tid = %d', $tid))) {
411,413c415,416
<     foreach ($fields as $field) {
<       $values[] = (string)db_escape_string($edit[$field]);
<     }
---
>     // Set the file path relative to the files directory
>     $file_path = str_replace(file_directory_path() .'/', '', $file->filepath);
415,416c418,419
<     db_query('INSERT INTO {term_image} (' .implode(', ', $fields). ') VALUES (\'' .implode('\', \'', $values). '\')');
<     cache_clear_all();
---
>     db_query('INSERT INTO {term_image} (tid, path) VALUES (\'%s\', \'%s\')', $tid, $file_path);
>     cache_clear_all(); // @todo do we need to clear the whole cache?  Can't we just clear taxonomy_image bits of the cache?
420,421c423,424
<   else if (!file_check_directory(file_create_path(variable_get('taxonomy_image_path', 'category_pictures')))) {
<     // we know waht's wrong, so generate a more useful error message
---
>   else if (!file_check_directory($directory)) {
>     // we know what's wrong, so generate a more useful error message
