You are here

function _imagepicker_get_bytes in Image Picker 7

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

File

./imagepicker.functions.inc, line 2126
@author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function _imagepicker_get_bytes($img_id, $account = FALSE) {
  if ($account) {
    $user = $account;
    $userdir = array(
      '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);
    if (file_exists($path . IMAGEPICKER_ORIG_DIR . '/' . $img->img_name)) {
      $originfo = image_get_info($path . IMAGEPICKER_ORIG_DIR . '/' . $img->img_name);
    }
    else {
      $originfo = array(
        'file_size' => 0,
      );
    }
    $tot = $fullinfo['file_size'] + $thumbsinfo['file_size'] + $browserinfo['file_size'] + $originfo['file_size'];
  }
  else {
    drupal_set_message(t('Image not found.'), 'error');
  }
  return $tot;
}