Migration of our hostname to lab.lostb.one is done. Redirects are intact until March.

Commit 6b5a8e9c authored by Che's avatar Che

Add limit parameter & minor cleanups

- Limit the size of the thumbnail parameter
- Add limit parameter to override the number of thumbnails in the grid
- Fix use of FILTER_SANITIZE_URL instead of FILTER_SANITIZE_STRING
- Restructure the grid building
parent c2ee6264
......@@ -37,7 +37,11 @@ if (!isset($_GET['refresh']) || filter_var($_GET['refresh'], FILTER_SANITIZE_STR
$size = 24;
if (isset($_GET['size'])) {
$size = filter_var($_GET['size'], FILTER_SANITIZE_NUMBER_INT);
$getSize = filter_var($_GET['size'], FILTER_SANITIZE_NUMBER_INT);
// Make sure the size of the thumbnails is between 5px and 400px.
if ($getSize >= 5 && $getSize <= 400) {
$size = $getSize;
}
}
echo " width: " . $size . "px;\n";
......@@ -144,8 +148,6 @@ if (!isset($_GET['ratio']) || filter_var($_GET['ratio'], FILTER_SANITIZE_STRING)
<!-- GCB (d7dd0d), 2018 -->
<div class="wrapImages">
<?php
// imgLimit defines the number of images which should be drawn
$imgLimit = 2800;
// fullpath is the pattern for selecting the images from the source directory
$fullpath = "/var/www/gallery/thumbs/*@*.*";
// newbase defines the base path to use for the image links
......@@ -157,15 +159,31 @@ usort($images, function($a, $b) {
return filemtime($a) < filemtime($b);
});
// imgLimit defines the number of thumbnails which should be drawn.
$imgLimit = 2800;
if (isset($_GET['limit'])) {
$getLimit = filter_var($_GET['limit'], FILTER_SANITIZE_NUMBER_INT);
// Make sure the grid is built out of between 400 and 4000 thumbnails.
if ($getLimit >= 400 && $getLimit <= 4000) {
$imgLimit = $getLimit;
}
}
// Don't use captions by default.
$useCaption = false;
if (isset($_GET['caption'])) {
if (filter_var($_GET['caption'], FILTER_SANITIZE_URL) == "y") {
if (filter_var($_GET['caption'], FILTER_SANITIZE_STRING) == "y") {
$useCaption = true;
}
}
// curVal holds the current value of iterations while building the grid.
$curVal = 0;
foreach ($images as $image) {
if ($curVal == $imgLimit) {
break;
}
$child = basename($image);
$expChild = explode("@", $child);
$signature = explode("-", $expChild[0], 2);
......@@ -183,15 +201,12 @@ foreach ($images as $image) {
}
echo $entry;
$curVal++;
}
$imgCount = count($images);
if ($imgLimit > $imgCount) {
if ($imgLimit > $curVal) {
// Fill the remaining page with placeholders
$curLimit = $imgLimit - $imgCount;
$curVal = 0;
while ($curLimit > $curVal) {
while ($imgLimit > $curVal) {
echo "<figure></figure>";
$curVal++;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment