thumb: decide on cache location in mkthumb()
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 7 Jul 2018 11:28:08 +0000 (13:28 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 7 Jul 2018 11:42:39 +0000 (13:42 +0200)
thumb/index.php

index 1267919810daf320bbb9e00b9b9e2afd66d5674d..2849bb50d59f689bfdc927a34ae0b1eb04938f34 100644 (file)
@@ -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)