X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/db3b8b188b7cc8b93948fd09e537ce92a0146f7e..e0c43cd6e50d762ea564faf17a9aa4a21ca72ffb:/foto/index.php diff --git a/foto/index.php b/foto/index.php index e7f1bab..8ba7db1 100644 --- a/foto/index.php +++ b/foto/index.php @@ -6,7 +6,17 @@ $nav[0] = "Foto's"; # override of root 'foto' $title = array_pop($nav); $Page->title = ($nav ? implode(' ', $nav) . ': ' : '') . $title; -if ($Page->api) { +if ($_SERVER['HTTP_ACCEPT'] === 'application/json') { + header('Access-Control-Allow-Origin: *'); + $imgs = []; + foreach (glob("$rootdir/*.jpg") as $path) { + $target = preg_replace('{^(\.\./)*}', '', readlink($path)); + $imgs[] = ["/$target"]; + } + print json_encode($imgs); + exit; +} +elseif ($Page->api) { $img = "$rootdir/index.jpg"; if (file_exists($img)) { # cover image of current album