From c83eac8c3cd448deec434cda6d7f55b55709fac4 Mon Sep 17 00:00:00 2001 From: Mikael Roos Date: Fri, 21 Nov 2014 20:20:35 +0100 Subject: [PATCH] Changing `CImage::output()` as proposed in #37. --- CImage.php | 11 +++++++---- README.md | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CImage.php b/CImage.php index 22f5a32..30e0aec 100644 --- a/CImage.php +++ b/CImage.php @@ -1547,10 +1547,8 @@ class CImage $this->log("Outputting image: $file"); - // Get details on image - $info = list($width, $height, $type, $attr) = getimagesize($file); - !empty($info) or $this->raiseError("The file doesn't seem to be an image."); - $mime = $info['mime']; + // Get image modification time + clearstatcache(); $lastModified = filemtime($file); $gmdate = gmdate("D, d M Y H:i:s", $lastModified); @@ -1576,6 +1574,11 @@ class CImage exit; } + // Get details on image + $info = getimagesize($file); + !empty($info) or $this->raiseError("The file doesn't seem to be an image."); + $mime = $info['mime']; + header('Content-type: ' . $mime); readfile($file); } diff --git a/README.md b/README.md index c8660d8..c8c89a2 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ Revision history v0.5.x (latest) +* Changing `CImage::output()` as proposed in #37. * Adding security check that image filename is always below the path `image_path` as specified in `img_config.php` #37. * Adding configuration item in `img_config.php` for setting valid characters in image filename. * Moving `webroot/test*` into directory `webroot/test`.