I use the flicksync module, and I supplement it with my own custom module. When an image is uploaded, the image is always uploaded the 'files' root directory. I want to have my 'files' directory clean, and so I create a new folder ('flickr_uploads') to upload the flickr images.

For the $directory variable, it is set to 'file_create_path()', without any arguments, so that it will always default to 'files'. This can be changed very easily if in your function you add a $path argument. For example:

   /**
    * Work out the path to a photo - also handles the cache on the local filesystem
    */
   function flickrsync_download_photo($flickr_photo, $size = FALSE, $path = FALSE) {
 
        ...code
        ...code
        $directory = file_create_path($path);

    } 

Anything any programmer passes to $path will work, as long as that folder is created and writable on the server. It works for me, and I've patched this, but I think this feature will help a lot of programmers that contribute and extend this module. All you have to add is the optional $path argument.

Thanks.

Comments

gclicon’s picture

Status: Active » Closed (fixed)

This is a great suggestion. I have committed a variation of this into 6.x-1.x-dev and will be included in the next release.

Instead of adding:

  $directory = file_create_path($path);

I added a check to take the cck default field path into account when there is no $path argument:

    if (!$path) {
      $imagefield = variable_get('flickrsync_image_field', '');
      $cck = content_types(variable_get('flickrsync_node_type', ''));
      $cck_path = '/' . $cck['fields'][$imagefield]['widget']['file_path'];
      $directory = file_create_path() . $cck_path;
    }
    else {
      $directory = file_create_path($path);
    }