Fixed thumbnails for non-image uploads

This commit is contained in:
Marcin Kurczewski 2014-08-03 23:00:27 +02:00
parent 42d814656a
commit ea5a07b509

View file

@ -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);
}