diff --git a/src/Imagine/Loader/FileSystemLoader.php b/src/Imagine/Loader/FileSystemLoader.php index 0aeb13f..0df640b 100644 --- a/src/Imagine/Loader/FileSystemLoader.php +++ b/src/Imagine/Loader/FileSystemLoader.php @@ -24,7 +24,7 @@ class FileSystemLoader implements LoaderInterface public function __construct(ResolverInterface $resolver) { $this->resolver = $resolver; - $this->loader = new SimpleFileSystemLoader(''); + $this->loader = new SimpleFileSystemLoader(null); } /** diff --git a/src/Imagine/Loader/SimpleFileSystemLoader.php b/src/Imagine/Loader/SimpleFileSystemLoader.php index 4ea1e62..07d85f0 100644 --- a/src/Imagine/Loader/SimpleFileSystemLoader.php +++ b/src/Imagine/Loader/SimpleFileSystemLoader.php @@ -32,7 +32,11 @@ public function load($path) ); } - $absolutePath = $this->rootPath . '/' . ltrim($path, '/'); + if ($this->rootPath === null) { + $absolutePath = $path; + } else { + $absolutePath = $this->rootPath . '/' . ltrim($path, '/'); + } if (!file_exists($absolutePath)) { throw new Exception\ImageNotFoundException(sprintf('Source image not found in "%s"', $absolutePath)); diff --git a/src/View/Strategy/ImageStrategy.php b/src/View/Strategy/ImageStrategy.php index 27915a7..5dc7ce7 100644 --- a/src/View/Strategy/ImageStrategy.php +++ b/src/View/Strategy/ImageStrategy.php @@ -90,6 +90,34 @@ public function injectResponse(ViewEvent $e) $response = $e->getResponse(); $response->setContent($result); + + $response->getHeaders()->addHeaderLine('Content-type', $this->getMimeType($model->getFormat())); } } + + /** + * Internal + * + * Get the mime type based on format. + * + * @param string $format + * + * @return string mime-type + * + * @throws RuntimeException + */ + protected function getMimeType($format) + { + static $mimeTypes = array( + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'pjpeg' => 'image/jpeg', + 'gif' => 'image/gif', + 'png' => 'image/png', + 'wbmp' => 'image/vnd.wap.wbmp', + 'xbm' => 'image/xbm', + ); + + return $mimeTypes[$format]; + } }