function imagepicker_get_path in Image Picker 5
Same name and namespace in other branches
- 5.2 imagepicker.module \imagepicker_get_path()
- 6.2 imagepicker.module \imagepicker_get_path()
- 7 imagepicker.module \imagepicker_get_path()
5 calls to imagepicker_get_path()
- 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 form
- imagepicker_user_view in ./
imagepicker.module
File
- ./
imagepicker.module, line 318 - 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' . $dirsep;
if ($userdir) {
$username = !is_array($userdir) ? $user->name : $userdir['name'];
$firstletter = strtolower(substr($username, 0, 1));
$firstletter = preg_match('/^[a-z]$/', $firstletter) ? $firstletter : 'others';
$path .= $firstletter . $dirsep . $username . $dirsep;
}
return $path;
}