function imagepicker_get_image_path in Image Picker 6.2
Same name and namespace in other branches
- 5.2 imagepicker.module \imagepicker_get_image_path()
- 5 imagepicker.module \imagepicker_get_image_path()
- 7 imagepicker.module \imagepicker_get_image_path()
10 calls to imagepicker_get_image_path()
- imagepicker_admin_images in ./
imagepicker.admin.inc - imagepicker_admin_view in ./
imagepicker.admin.inc - imagepicker_display_block in ./
imagepicker.module - Function to display the contents of a block.
- imagepicker_image_page in ./
imagepicker.functions.inc - Menu callback; presents the image page for imagepicker
- imagepicker_user_view in ./
imagepicker.user.inc
File
- ./
imagepicker.module, line 904 - Enables permitted roles to upload images for insertion into configured nodes.
Code
function imagepicker_get_image_path($img, $type = 'browser', $public = FALSE, $preset = FALSE) {
$userdir = is_array($public) ? $public : TRUE;
$imgbasedir = imagepicker_get_path(FALSE, $userdir);
$found = FALSE;
// $img is object or array
if (is_object($img)) {
$img_name = $img->img_name;
}
else {
$img_name = $img['img_name'];
}
switch ($type) {
case 'browser':
if (file_exists($imgbasedir . IMAGEPICKER_BROWSER_DIR . DIRECTORY_SEPARATOR . $img_name)) {
$suffix = IMAGEPICKER_BROWSER_DIR;
$found = TRUE;
}
elseif (file_exists($imgbasedir . IMAGEPICKER_THUMBS_DIR . DIRECTORY_SEPARATOR . $img_name)) {
$suffix = IMAGEPICKER_THUMBS_DIR;
$found = TRUE;
}
break;
case 'full':
if (file_exists($imgbasedir . $img_name)) {
$suffix = NULL;
$found = TRUE;
}
break;
case 'thumb':
default:
if (file_exists($imgbasedir . IMAGEPICKER_THUMBS_DIR . DIRECTORY_SEPARATOR . $img_name)) {
$suffix = IMAGEPICKER_THUMBS_DIR;
$found = TRUE;
}
elseif (file_exists($imgbasedir . IMAGEPICKER_BROWSER_DIR . DIRECTORY_SEPARATOR . $img_name)) {
$suffix = IMAGEPICKER_BROWSER_DIR;
$found = TRUE;
}
break;
case 'watermarks':
if (file_exists($imgbasedir . $img_name)) {
$suffix = IMAGEPICKER_WATERMARK_DIR;
$found = TRUE;
}
break;
case 'orig':
if (file_exists($imgbasedir . $img_name)) {
$suffix = IMAGEPICKER_ORIG_DIR;
$found = TRUE;
}
break;
}
if ($found) {
if ($suffix) {
if (variable_get('imagepicker_use_full_url', 0) || variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
if (module_exists('imagecache') && variable_get('imagepicker_imagecache_enable', 0) && $preset && $suffix == IMAGEPICKER_THUMBS_DIR) {
$imgpath = imagecache_create_url('__PRESET__', IMAGEPICKER_FILES_DIR . '/' . imagepicker_get_userpath($userdir) . $suffix . '/' . $img_name);
}
else {
$imgpath = file_create_url(IMAGEPICKER_FILES_DIR . '/' . imagepicker_get_userpath($userdir) . $suffix . '/' . $img_name);
}
}
else {
if (module_exists('imagecache') && variable_get('imagepicker_imagecache_enable', 0) && $preset && $suffix == IMAGEPICKER_THUMBS_DIR) {
$imgpath = base_path() . imagecache_create_path('__PRESET__', IMAGEPICKER_FILES_DIR . '/' . imagepicker_get_userpath($userdir) . $suffix . '/' . $img_name);
}
else {
$imgpath = imagepicker_get_path(TRUE, $userdir) . $suffix . '/' . $img_name;
}
}
}
else {
if (variable_get('imagepicker_use_full_url', 0) || variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
if (module_exists('imagecache') && variable_get('imagepicker_imagecache_enable', 0) && $preset) {
$imgpath = imagecache_create_url('__PRESET__', IMAGEPICKER_FILES_DIR . '/' . imagepicker_get_userpath($userdir) . $img_name);
}
else {
$imgpath = file_create_url(IMAGEPICKER_FILES_DIR . '/' . imagepicker_get_userpath($userdir) . $img_name);
}
}
else {
if (module_exists('imagecache') && variable_get('imagepicker_imagecache_enable', 0) && $preset) {
$imgpath = base_path() . imagecache_create_path('__PRESET__', IMAGEPICKER_FILES_DIR . '/' . imagepicker_get_userpath($userdir) . $img_name);
}
else {
$imgpath = imagepicker_get_path(TRUE, $userdir) . $img_name;
}
}
}
}
return $imgpath ? $imgpath : '';
}