You are here

function imagecache_transfer in ImageCache 5.2

Same name and namespace in other branches
  1. 6.2 imagecache.module \imagecache_transfer()

helper function to transfer files from imagecache. Determines mime type and sets a last modified header.

Parameters

$path path to file to be transferred.:

Return value

<exit>

2 calls to imagecache_transfer()
imagecache_cache_private in ./imagecache.module
callback for handling private files imagecache requests
_imagecache_cache in ./imagecache.module
handle request validation and responses to imagecache requests.

File

./imagecache.module, line 394
Dynamic image resizer and image cacher.

Code

function imagecache_transfer($path) {
  if (function_exists('mime_content_type')) {
    $mime = mime_content_type($path);
  }
  else {
    $size = getimagesize($path);
    $mime = $size['mime'];
  }
  $headers = array(
    'Content-Type: ' . mime_header_encode($mime),
  );
  if ($fileinfo = stat($path)) {
    $headers[] = 'Content-Length: ' . $fileinfo[7];
    $headers[] = 'Expires: ' . gmdate('D, d M Y H:i:s', time() + 1209600) . ' GMT';
    $headers[] = 'Cache-Control: max-age=1209600, private, must-revalidate';
    _imagecache_cache_set_cache_headers($fileinfo, $headers);
  }
  file_transfer($path, $headers);
  exit;
}