You are here

function _imagepicker_get_bytes in Image Picker 5.2

Same name and namespace in other branches
  1. 6.2 imagepicker.functions.inc \_imagepicker_get_bytes()
  2. 7 imagepicker.functions.inc \_imagepicker_get_bytes()
1 call to _imagepicker_get_bytes()
imagepicker_get_all_bytes in ./imagepicker.module

File

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

Code

function _imagepicker_get_bytes($img_id, $account = FALSE) {
  if ($account) {
    $user = $account;
    $userdir = array(
      'name' => $user->name,
      'uid' => $user->uid,
    );
  }
  else {
    global $user;
    $userdir = FALSE;
  }
  $tot = 0;
  $img = _imagepicker_get_img($img_id, FALSE, $user);
  if ($img) {
    $path = imagepicker_get_path(FALSE, $userdir);
    $fullinfo = image_get_info($path . $img['img_name']);
    $thumbsinfo = image_get_info($path . IMAGEPICKER_THUMBS_DIR . '/' . $img['img_name']);
    $browserinfo = image_get_info($path . IMAGEPICKER_BROWSER_DIR . '/' . $img['img_name']);
    $tot = $fullinfo['file_size'] + $thumbsinfo['file_size'] + $browserinfo['file_size'];
  }
  else {
    drupal_set_message(t('Image not found.'), 'error');
  }
  return $tot;
}