src/Image.php
public function passthru($filepath, $info = array())
	{
		$this->debug->group(__METHOD__);
		// $this->debug->log('info', $info);
		$info = array_merge(array(
			'filename'	=> null,
			'md5'		=> null,
			'mime'		=> 'image/jpeg',
			'size'		=> null,
		), $info);
		if (file_exists($filepath)) {
			if (empty($info['md5'])) {
				$info['md5'] = md5_file($filepath);
			}
			if (empty($info['size'])) {
				$info['size'] = filesize($filepath);
			}
			$headers = apache_request_headers();
			$this->debug->log('headers', $headers);
			$this->debug->log('info[md5]', $info['md5']);
			if (isset($headers['If-None-Match']) && $headers['If-None-Match'] == $info['md5']) {
				header('HTTP/1.1 304 Not Modified');
			} else {
				header('Content-Type: '.$info['mime']);
				header('ETag: '.$info['md5']);
				header('Content-Length: '.$info['size']);
				// header('Cache-Control: must-revalidate');
				header('Last Modified: '.gmdate('D, d M Y H:i:s \G\M\T'));
				if ($info['filename']) {
					header('Content-Disposition: inline; filename="'.$info['filename'].'"');
				}
				readfile($filepath);
			}
		} else {
			$this->debug->warn('file does not exist', $filepath);
		}
		$this->debug->groupEnd();
		return;
	}
public function passthru($filepath, $info = array())
	{
		$this->debug->group(__METHOD__);
		// $this->debug->log('info', $info);
		$info = array_merge(array(
			'filename'	=> null,
			'md5'		=> null,
			'mime'		=> 'image/jpeg',
			'size'		=> null,
		), $info);
		if (file_exists($filepath)) {
			if (empty($info['md5'])) {
				$info['md5'] = md5_file($filepath);
			}
			if (empty($info['size'])) {
				$info['size'] = filesize($filepath);
			}
			$headers = apache_request_headers();
			$this->debug->log('headers', $headers);
			$this->debug->log('info[md5]', $info['md5']);
			if (isset($headers['If-None-Match']) && $headers['If-None-Match'] == $info['md5']) {
				header('HTTP/1.1 304 Not Modified');
			} else {
				header('Content-Type: '.$info['mime']);
				header('ETag: '.$info['md5']);
				header('Content-Length: '.$info['size']);
				// header('Cache-Control: must-revalidate');
				header('Last Modified: '.gmdate('D, d M Y H:i:s \G\M\T'));
				if ($info['filename']) {
					header('Content-Disposition: inline; filename="'.$info['filename'].'"');
				}
				readfile($filepath);
			}
		} else {
			$this->debug->warn('file does not exist', $filepath);
		}
		$this->debug->groupEnd();
		return;
	}
public function passthru ( $ filepath , $ info = array ( ) ) { $ this -> debug -> group ( __METHOD__ ) ; // $this->debug->log('info', $info); $ info = array_merge ( array ( 'filename' => null , 'md5' => null , 'mime' => 'image/jpeg' , 'size' => null , ) , $ info ) ; if ( file_exists ( $ filepath ) ) { if ( empty ( $ info [ 'md5' ] ) ) { $ info [ 'md5' ] = md5_file ( $ filepath ) ; } if ( empty ( $ info [ 'size' ] ) ) { $ info [ 'size' ] = filesize ( $ filepath ) ; } $ headers = apache_request_headers ( ) ; $ this -> debug -> log ( 'headers' , $ headers ) ; $ this -> debug -> log ( 'info[md5]' , $ info [ 'md5' ] ) ; if ( isset ( $ headers [ 'If-None-Match' ] ) && $ headers [ 'If-None-Match' ] == $ info [ 'md5' ] ) { header ( 'HTTP/1.1 304 Not Modified' ) ; } else { header ( 'Content-Type: ' . $ info [ 'mime' ] ) ; header ( 'ETag: ' . $ info [ 'md5' ] ) ; header ( 'Content-Length: ' . $ info [ 'size' ] ) ; // header('Cache-Control: must-revalidate'); header ( 'Last Modified: ' . gmdate ( 'D, d M Y H:i:s \G\M\T' ) ) ; if ( $ info [ 'filename' ] ) { header ( 'Content-Disposition: inline; filename="' . $ info [ 'filename' ] . '"' ) ; } readfile ( $ filepath ) ; } } else { $ this -> debug -> warn ( 'file does not exist' , $ filepath ) ; } $ this -> debug -> groupEnd ( ) ; return ; }
Output image with headers

@param string $filepath file path
@param array  $info     filename, mime, filesize, etc

@return void
Output image with headers