Taxonomy image create file path like this: /files/category_pictures_1 is not very nice if you would like work on a specific image type with JavaScript (png for IE>7 for example).

Is better if you have a image path with the extension: http://www.itn.ch/fr/system/files/category_pictures_1.png

Comments

gagarine’s picture

oups sorry i write the full path..

Correct:
Is better if you have a image path with the extension: /files/category_pictures_1.png

nancydru’s picture

I don't know how it would work at all without the extension. Certainly on all my sites it shows the extension properly.

gagarine’s picture

stranger... perhaps a incompatibility with taxo + taxoimage + taxomenu + i18n
Any body can confirm?

nancydru’s picture

Hmm, I went to the site you have linked above and it is not a Drupal site. It is using frames - Drupal does not.

dman’s picture

Status: Active » Needs work

The PROBLEM is that the file_save_upload() and $taxonomy_image_path are not working as expected.
On a brand new install, the directory files/category_images does not exist, and it's not getting made automatically

in taxonomy_image_save(), saving the uploaded file to a directory that doesn't exist instead has the odd behaviour of just trying to save the image with the filename 'category_images' (no extension)
And subsequent uploads fill my file directory with files (category_images_1, category_images_2, category_images_3 etc)
They ARE image files, so work when they are called, but they have no extension, are in the wrong place, and have lost their original names. All very messy, and surely not what was intended.

You would not have seen this on a site where you'd already created the category_images dir by hand.

I only noticed it because I was trying to run pngfix on the images ... which, as described, had no extension.

Here's the fix, calling file_check_directory() just before trying to save :

function taxonomy_image_save($tid) {
  $edit['tid'] = $tid;
  $fields = array('tid', 'path');
  $directory = file_create_path(variable_get('taxonomy_image_path', 'category_pictures'));
  file_check_directory(&$directory, FILE_CREATE_DIRECTORY);
  if ($file = file_save_upload('path', $directory)) {
    $edit['path'] = $file->filepath;

I'm rolling a bigger patch right now, so my distro is unclean, so please add this by hand.

dman’s picture

http://drupal.org/node/164447 also identified the same problem

gagarine’s picture

yeah is not the drupal site because the drupal site is not ready for production now (but certenly in few week). This is the old site. Sorry...

Thanks for the "patch" :) and the explanation.

nancydru’s picture

Status: Needs work » Fixed

Fix committed.

nancydru’s picture

Assigned: Unassigned » nancydru

@dman - I wondered about that "&" in the "check_directory." I'm getting lots of this:

PHP Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of file_check_directory(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer.

So, I'm removing the "&".

dman’s picture

sorry. That was just a copy&paste leftover. And maybe PHP4 testing. I can't recall now.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.