p-view/index.php

43 lines
1.1 KiB
PHP

<!DOCTYPE HTML>
<html lang="en">
<link rel="stylesheet" type="text/css" href="assets/style.css">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="generator" content="xfnw/p-view">
<meta name="description" content="a tiny php script to automagically display photos">
<title>p-view</title>
<h1>p-view</h1>
tiny script to automagically display all the photos in a directory with php.
<a href='rss.php'>rss!</a>
<div class='wrapper'>
<?php
$images = glob("src/*.{png,jpg,JPG}", GLOB_BRACE);
usort( $images, function( $b, $a ) { return filemtime($a) - filemtime($b); } );
foreach($images as $image) {
$title = str_replace("_", " ", $image);
$title = str_replace("src/", "", $title);
$title = str_replace(".png", "", $title);
$title = str_replace(".jpg", "", $title);
$title = str_replace(".JPG", "", $title);
$anchor = str_replace(" ", "", $title);
?>
<div class='preview'>
<h1>
<a name="<?php echo $anchor; ?>" href="#<?php echo $anchor; ?>"><?php echo $title; ?></a>
</h1>
<img width="100%" loading="lazy" src="<?php echo $image; ?>" alt="<?php echo $title;?>">
</div>
<?php
}
?>
</html>