You are here

function imagepicker_get_image_path in Image Picker 5

Same name and namespace in other branches
  1. 5.2 imagepicker.module \imagepicker_get_image_path()
  2. 6.2 imagepicker.module \imagepicker_get_image_path()
  3. 7 imagepicker.module \imagepicker_get_image_path()
5 calls to imagepicker_get_image_path()
imagepicker_image_select in ./imagepicker.module
imagepicker_js in ./imagepicker.module
imagepicker_user_view in ./imagepicker.module
_imagepicker_browse in ./imagepicker.module
_imagepicker_edit_img in ./imagepicker.module

File

./imagepicker.module, line 401
Enables permitted roles to upload images for insertion into configured nodes.

Code

function imagepicker_get_image_path($img, $type = 'browser') {
  $imgbasedir = imagepicker_get_path(FALSE, TRUE);
  switch ($type) {
    case 'browser':
      if (file_exists($imgbasedir . 'browser' . DIRECTORY_SEPARATOR . $img['img_name'])) {
        $imgpath = imagepicker_get_path(TRUE, TRUE) . 'browser/' . $img['img_name'];
      }
      elseif (file_exists($imgbasedir . 'thumbs' . DIRECTORY_SEPARATOR . $img['img_name'])) {
        $imgpath = imagepicker_get_path(TRUE, TRUE) . 'thumbs/' . $img['img_name'];
      }
      break;
    case 'full':
      if (file_exists($imgbasedir . $img['img_name'])) {
        $imgpath = imagepicker_get_path(TRUE, TRUE) . $img['img_name'];
      }
      break;
    case 'thumb':
    default:
      if (file_exists($imgbasedir . 'thumbs' . DIRECTORY_SEPARATOR . $img['img_name'])) {
        $imgpath = imagepicker_get_path(TRUE, TRUE) . 'thumbs/' . $img['img_name'];
      }
      elseif (file_exists($imgbasedir . 'browser' . DIRECTORY_SEPARATOR . $img['img_name'])) {
        $imgpath = imagepicker_get_path(TRUE, TRUE) . 'browser/' . $img['img_name'];
      }
      break;
  }
  return $imgpath ? $imgpath : '';
}