function imagepicker_get_path in Image Picker 5.2
Same name and namespace in other branches
- 5 imagepicker.module \imagepicker_get_path()
- 6.2 imagepicker.module \imagepicker_get_path()
- 7 imagepicker.module \imagepicker_get_path()
8 calls to imagepicker_get_path()
- imagepicker_admin_view in ./
imagepicker.module - imagepicker_get_image_path in ./
imagepicker.module - imagepicker_image_delete in ./
imagepicker.module - imagepicker_image_page in ./
imagepicker.module - Menu callback; presents the image page for imagepicker
- imagepicker_upload_form_submit in ./
imagepicker.module - Submit upload form
File
- ./
imagepicker.module, line 473 - Enables permitted roles to upload images for insertion into configured nodes.
Code
function imagepicker_get_path($url = FALSE, $userdir = FALSE) {
global $user, $base_url;
$dirsep = !$url ? DIRECTORY_SEPARATOR : '/';
if (!$url) {
$path = str_replace('/', DIRECTORY_SEPARATOR, getcwd());
}
else {
if (variable_get('imagepicker_use_full_url', 1)) {
$path = $base_url;
}
else {
$path = base_path();
$path = preg_replace("/\\/\$/", "", $path);
}
}
$path .= $dirsep . file_directory_path() . $dirsep . IMAGEPICKER_FILES_DIR . $dirsep;
// old or new
$fstype = variable_get('imagepicker_fstype', '');
if ($userdir) {
if ($fstype == 'alpha') {
$username = !is_array($userdir) ? $user->name : $userdir['name'];
$firstletter = drupal_strtolower(drupal_substr($username, 0, 1));
$firstletter = preg_match('/^[a-z]$/', $firstletter) ? $firstletter : 'others';
$path .= $firstletter . $dirsep . $username . $dirsep;
}
else {
$useruid = !is_array($userdir) ? $user->uid : $userdir['uid'];
$path .= $useruid . $dirsep;
}
}
return $path;
}