24 lines
770 B
PHP
24 lines
770 B
PHP
<?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);
|
|
?>
|