From ea5a07b509dbe8533e121ef1a95dd311cab0455a Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sun, 3 Aug 2014 23:00:27 +0200 Subject: [PATCH] Fixed thumbnails for non-image uploads --- src/Controllers/PostController.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Controllers/PostController.php b/src/Controllers/PostController.php index 16c0606c..82c0ccc2 100644 --- a/src/Controllers/PostController.php +++ b/src/Controllers/PostController.php @@ -161,8 +161,17 @@ class PostController extends AbstractController $options->lastModified = time() - 3600; $options->cacheDaysToLive = 0.5; $options->mimeType = mime_content_type($tmpPath); - $options->fileHash = md5($url); - $options->fileContent = file_get_contents($tmpPath); + if (strpos($options->mimeType, 'image/') !== 0) //not an image + { + $options->mimeType = 'image/jpeg'; + $options->fileHash = 'thumb.jpg'; + $options->fileContent = file_get_contents(Core::getConfig()->main->mediaPath . DS . 'img' . DS . 'thumb.jpg'); + } + else + { + $options->fileHash = md5($url); + $options->fileContent = file_get_contents($tmpPath); + } $this->renderFile($options); }