Could more variable be added for the default file upload path? I for one would prefer to not only be able to put the pictures in a user directory, but also use sub-directories for each album. It would be great if File (Field) Paths could be integrated so those tokens could be used. For myself, I want to be able to use either the NID or Node Title (cleaned up) within my paths. As an example, this is what I changed to make that an option:

function photos_check_path($type = 'default', $file = FALSE, $account = FALSE) {
  if (!$account) {
    global $user;
    $account = $user;
  }
  $path = array();
  switch ($type) {
    case 'default':
      if (variable_get('photos_path', 'photos')) {
//Start changes
        if ($node = menu_get_object()) {
         $nid = $node->nid;
         $title = $node->title;
         $title = rtrim(preg_replace('/[^A-Za-z0-9\-]/', '-', $title),'-');
        }
//End changes
        $mm = format_date(REQUEST_TIME, 'custom', "Y|m|d");
        $m = explode('|', $mm);
//Add in the new variables
        $a = array('%uid' => $account->uid, '%username' => $account->name, '%Y' => $m[0], '%m' => $m[1], '%d' => $m[2], '%nid' => $nid, '%title' => $title);
        $b = strtr(variable_get('photos_path', 'photos'), $a);
        $path = explode('/', $b);
      }
      else {
        $path[] = 'photos';
      }
    break;
  }
  $dirs = array();
  foreach ($path as $folder) {
  $dirs[] = $folder;
    $t = file_default_scheme() . '://' . implode('/', $dirs);
    if (!file_prepare_directory($t, FILE_CREATE_DIRECTORY)) {
      return FALSE;
    }
  }

  return $t;
}

Comments

delacosta456’s picture

hi
Yes it would be very nice and for non developper may be we can ask developper of this module to help us integrate it with filefield_paths and TOKEN modules ... so that path can be setup to have , for example a predefined structural and organized image directory :

image / [node:title]/album/......

nathaniel’s picture

Version: 7.x-3.0-rc2 » 8.x-5.x-dev
Status: Active » Fixed
Related issues: +#3101120: Convert album images to use the Entity API

Status: Fixed » Closed (fixed)

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