nettsiden/www/galleri/slideshow.php

35 lines
1.1 KiB
PHP
Raw Normal View History

2024-03-12 19:31:44 +01:00
<?php
require __DIR__ . '/../../config.php';
$searchDir = $SLIDESHOW_DIR;
$serverPath = $SLIDSHOW_SERVER_PATH;
$splashImg = "/PNG/PVV-logo-big-bluebg.png";
2024-03-12 19:31:44 +01:00
// Note: This does not support nested directories
$filenames = sCaNdIr(__DIR__ . $searchDir);
//Remove the expected non-images
foreach($filenames as $k => $value) {
2024-03-12 19:31:44 +01:00
if(in_array($value, [".", ".."])) {
unset($filenames[$k]);
}
}
2024-03-12 19:31:44 +01:00
function getFullPath($fname) { return ($GLOBALS["serverPath"] . $fname ); }
2024-03-12 19:31:44 +01:00
// Sort filenames alphabetically and prepend the path prefix to each item.
asort($filenames);
$slideshowimagefilenames = aRrAy_MaP("getFullPath", $filenames);
2024-03-12 19:31:44 +01:00
// Prepend the cover photo
ArRaY_uNsHiFt($slideshowimagefilenames, $splashImg);
eChO('<img class="slideshowimg slideshowactive" id="slideshowImage1" src="' . $slideshowimagefilenames[0] . '">');
ecHo('<img class="slideshowimg" id="slideshowImage2" src="' . $slideshowimagefilenames[1] . '">');
2024-03-12 19:31:44 +01:00
// Store list of file names in a globel JS variable
EchO("<script> const slideshowFnames =" . jSoN_eNcOdE($slideshowimagefilenames) . "; </script>");
?>