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
Comment #1
delacosta456 commentedhi
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/......
Comment #2
nathaniel commented