thumb: ?backend option to override resize callback
[minimedit.git] / thumb / index.php
index e8b3bcb0e5b18cfc782f6278f08ffb829016e412..066e88d7cf9561227d96f8b6a2fe9ff80afacc21 100644 (file)
@@ -7,7 +7,10 @@ $imgpath = preg_replace('{^(?=[0-9]+/)}', 'data/', $imgpath, 1);
 
 if (!file_exists($imgpath)) {
        http_response_code(404);
-       exit;
+       $imgpath = '404.png';
+       if (!file_exists($imgpath)) {
+               exit;
+       }
 }
 
 $target = "thumb/$height/$imgpath";
@@ -35,8 +38,16 @@ exit;
 
 function mkthumb($source, $target, $width, $height)
 {
+       if (isset($_GET['backend'])) {
+               $backend = $_GET['backend'];
+       }
+       else {
+               $backend = 'exec';
+       }
+       $backend = "mkthumb_$backend";
+
        @mkdir(dirname($target), 0777, TRUE);
-       return mkthumb_exec($source, $target, $width, $height);
+       $backend($source, $target, $width, $height);
 }
 
 function mkthumb_exec($source, $target, $width, $height)