intial commit
This commit is contained in:
24
list-images.php
Normal file
24
list-images.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
$dir = __DIR__ . '/images/';
|
||||
$thumbDir = $dir . 'thumbnails/';
|
||||
$extensions = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp'];
|
||||
$images = [];
|
||||
|
||||
if (is_dir($dir)) {
|
||||
foreach (scandir($dir) as $file) {
|
||||
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
|
||||
if (in_array($ext, $extensions)) {
|
||||
$thumbPath = 'images/thumbnails/' . $file;
|
||||
$fullPath = 'images/' . $file;
|
||||
// Check if thumbnail exists
|
||||
if (file_exists($thumbDir . $file)) {
|
||||
$images[] = ['thumb' => $thumbPath, 'full' => $fullPath];
|
||||
} else {
|
||||
$images[] = ['thumb' => $fullPath, 'full' => $fullPath];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($images);
|
||||
?>
|
||||
Reference in New Issue
Block a user