From: Mischa POSLAWSKY Date: Sat, 7 Jul 2018 11:28:08 +0000 (+0200) Subject: thumb: decide on cache location in mkthumb() X-Git-Tag: v3.3~11 X-Git-Url: http://git.shiar.net/minimedit.git/commitdiff_plain/f08646f0f4d2dfe6ba6d4804e0439777c3eb8f77 thumb: decide on cache location in mkthumb() --- 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)