From f08646f0f4d2dfe6ba6d4804e0439777c3eb8f77 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sat, 7 Jul 2018 13:28:08 +0200 Subject: [PATCH] thumb: decide on cache location in mkthumb() --- thumb/index.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/thumb/index.php b/thumb/index.php index 1267919..2849bb5 100644 --- a/thumb/index.php +++ b/thumb/index.php @@ -13,9 +13,8 @@ if (!file_exists($imgpath)) { } } -$target = "thumb/$height/$imgpath"; try { - mkthumb($imgpath, $target, $width, $height); + $target = mkthumb($imgpath, $width, $height); } catch (Exception $e) { http_response_code($e->getCode() ?: 500); @@ -34,8 +33,10 @@ header('Content-type: '.mime_content_type($target)); readfile($target); exit; -function mkthumb($source, $target, $width, $height) +function mkthumb($source, $width, $height) { + $target = "thumb/$height/$source"; + if (isset($_GET['backend'])) { $backend = $_GET['backend']; } @@ -49,6 +50,7 @@ function mkthumb($source, $target, $width, $height) @mkdir(dirname($target), 0777, TRUE); $backend($source, $target, $width, $height); + return $target; } function mkthumb_exec($source, $target, $width, $height) -- 2.30.0