From e92ac584f26d90c0522314930df7019f372a8c24 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 | 9 ++++++++- www/js/slideshow.js | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/www/galleri/index.php b/www/galleri/index.php index b626216..8b1b8b7 100644 --- a/www/galleri/index.php +++ b/www/galleri/index.php @@ -52,6 +52,14 @@ function getDirContents($dir, &$results = array()) { } $images = getDirContents($galleryDir); +function cmpModifyTime($a, $b) { + $mtime_a = filemtime($galleryDir . $a); + $mtime_b = filemtime($galleryDir . $b); + return ($mtime_a > $mtime_b) ? -1 : 1; +} + +usort($images, "cmpModifyTime"); + $imageTemplate = '
@@ -105,7 +113,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 +}