From 9d9d99e6ba788ea12b4aca0f250522af99f5da1e Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Sun, 14 Apr 2024 00:38:14 +0200 Subject: [PATCH] gallery: sort by timestamp. slideshow: fix transition bug on firefox --- www/galleri/index.php | 12 +++++++++++- www/js/slideshow.js | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/www/galleri/index.php b/www/galleri/index.php index b626216..cf18e26 100644 --- a/www/galleri/index.php +++ b/www/galleri/index.php @@ -52,6 +52,17 @@ function getDirContents($dir, &$results = array()) { } $images = getDirContents($galleryDir); +function cmpModifyTime($a, $b) { + global $galleryDir; + + $mtime_a = filemtime($galleryDir . $a); + $mtime_b = filemtime($galleryDir . $b); + + return ($mtime_a > $mtime_b) ? -1 : 1; +} + +usort($images, "cmpModifyTime"); + $imageTemplate = '
@@ -105,7 +116,6 @@ $imageTemplate = ' $vars = [ "%user" => htmlspecialchars($imguser), "%time" => $modTime, - "%timestamp" => filemtime($galleryDir . $value), "%name" => htmlspecialchars($displaypath), "%path" => $serverPath . $value, "%thumbnail" => $serverPath . "/.thumbnails" . $value . ".png", diff --git a/www/js/slideshow.js b/www/js/slideshow.js index ac27a9f..eb12e18 100644 --- a/www/js/slideshow.js +++ b/www/js/slideshow.js @@ -21,7 +21,7 @@ function stepSlideshow(imgs) { //Change source to next picture after it is faded out slideshowIndex = (slideshowIndex + 1) % imgs.length; ssi2.src = slideshowFnames[slideshowIndex]; - }, 800); + }, 1000); } //Initialize slideshow, start interval @@ -29,4 +29,4 @@ if (slideshowFnames.length > 1) { slideshowInterval = setInterval(()=>{ stepSlideshow(slideshowFnames); }, SLIDESHOWDELAYMS); -} \ No newline at end of file +}