-
Notifications
You must be signed in to change notification settings - Fork 0
/
galleri.php
55 lines (53 loc) · 1.45 KB
/
galleri.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
include("incl/multipage.php");
$title = "Galleri";
include("incl/header.php");
$directory = "img/150x150";
$images = glob($directory . "/*.jpg");
$nrOfImages = count($images);
$startNr = $_GET['image-page-nr'] ?? 0;
$aTag = '<a href="?image-page-nr=$linkId">$Value</a>';
if ($startNr > 0) {
$replacement['$linkId'] = $startNr - 9;
$replacement['$Value'] = 'Föregående';
$previousItemLink = strtr($aTag, $replacement);
} else {
$previousItemLink = '<div></div>';
}
if ($startNr + 9 < $nrOfImages) {
$replacement['$linkId'] = $startNr + 9;
$replacement['$Value'] = 'Nästa';
$nextItemLink = strtr($aTag, $replacement);
} else {
$nextItemLink = '<div></div>';
}
?>
<main>
<article class="all-browsers">
<header class="grid">
<?= $previousItemLink ?>
<h1>Bildgalleri</h1>
<?= $nextItemLink ?>
</header>
<div class="grid9">
<?php
foreach (array_slice($images, $startNr, 9) as $image) {
$largeImage = 'img/orig/' . basename($image);
echo <<<IMG
<div class="div-content">
<figure>
<a href="$largeImage">
<img src="$image" alt="$image">
</a>
<figcaption>$image</figcaption>
</figure>
</div>
IMG;
}
?>
</div>
</article>
</main>
<?php
include("incl/footer.php");
?>