You are here

function photos_get_thumb in Album Photos 6.2

2 calls to photos_get_thumb()
photos_get_info in ./photos.module
photos_image_get in inc/photos.image.inc

File

./photos.module, line 921

Code

function photos_get_thumb($filepath, $fid, $thumb, $set = 0) {
  if (is_file($filepath) && $thumb) {
    $filename = end(explode('/', $filepath));
    $thumblabel = $thumb['w'] . 'x' . $thumb['h'] . '_' . $thumb['r'] . '_thumb';
    $thumbfilepath = str_replace($filename, 'thumb_' . $fid . '/' . $thumblabel . '_' . $filename, $filepath);
    if (!$set || is_file($thumbfilepath)) {
      return $thumbfilepath;
    }
    $image = image_get_info($filepath);
    if ($set && ($image['width'] > $thumb['w'] || $image['height'] > $thumb['h'])) {
      if (photos_image_crop(array(
        'path' => $filepath,
        'fid' => $fid,
        'size' => array(
          array(
            't' => $t,
            'w' => $thumb['w'],
            'h' => $thumb['h'],
            'r' => $thumb['r'],
          ),
        ),
      ))) {
        return $thumbfilepath;
      }
    }
    else {
      return $filepath;
    }
  }
  return false;
}