You are here

function photos_image_get in Album Photos 6.2

Same name and namespace in other branches
  1. 7.3 inc/photos.image.inc \photos_image_get()
1 string reference to 'photos_image_get'
photos_menu in ./photos.module

File

inc/photos.image.inc, line 89

Code

function photos_image_get($fid, $thumb) {
  $filepath = str_replace('photos/get/' . $fid . '/' . $thumb . '/', '', $_GET['q']);
  if (!is_file($filepath)) {
    if ($thumb != 'original' && ($thumb = _photos_get_thumbname($thumb))) {
      $str = "/thumb_{$fid}.*?thumb_/i";
      $original = preg_replace($str, '', $filepath);
      if (is_file($original) && ($filepath = photos_get_thumb($original, $fid, $thumb, 1))) {
        $true = 1;
      }
    }
    if (!$true) {
      drupal_set_header('Content-Type: text/plain;');
      echo t('Image does not exist');
      exit;
    }
  }
  $image = end(explode('.', $_GET['q']));
  header('Content-type: image/' . $image);
  if ($fd = @fopen($filepath, 'rb')) {
    while (!feof($fd)) {
      print fread($fd, 1024);
    }
    fclose($fd);
    exit;
  }
  drupal_set_header('Content-Type: text/plain;');
  echo t('Image does not exist');
  exit;
}