Slight refactoring
This commit is contained in:
parent
792b9c875f
commit
2bfa19fe24
23
php/get.php
23
php/get.php
@ -24,8 +24,6 @@ define("VIDEO_EXTENSIONS", [
|
||||
|
||||
define("FILE_EXTENSIONS", array_merge(IMAGE_EXTENSIONS, VIDEO_EXTENSIONS));
|
||||
|
||||
main();
|
||||
|
||||
function main(): void {
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$array = [];
|
||||
@ -42,15 +40,17 @@ function main(): void {
|
||||
$is_dir = is_dir(ROOT_DIR.IMG_DIR.$path);
|
||||
if (!$is_dir && !is_valid_file_type($file)) continue;
|
||||
|
||||
$url = ROOT_URL.IMG_DIR.$path;
|
||||
$thumbnail_url = null;
|
||||
|
||||
if (!$is_dir) {
|
||||
$thumbnail_url = create_thumbnail($category, $file);
|
||||
}
|
||||
|
||||
$file_item = [];
|
||||
$file_item["is_dir"] = $is_dir;
|
||||
if ($is_dir) {
|
||||
$file_item["url"] = ROOT_URL.IMG_DIR.$path;
|
||||
$file_item["thumbnail_url"] = null;
|
||||
} else {
|
||||
$file_item["url"] = ROOT_URL.IMG_DIR.$path;
|
||||
$file_item["thumbnail_url"] = create_thumbnail($category, $file);
|
||||
}
|
||||
$file_item["url"] = $url;
|
||||
$file_item["thumbnail_url"] = $thumbnail_url;
|
||||
array_push($array, $file_item);
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ function create_thumbnail(string $category, string $file): string | null {
|
||||
$thumbnail_file = $thumbnail_directory.$file;
|
||||
|
||||
if (file_exists($thumbnail_file)) {
|
||||
log_print("$thumbnail_file exists, skipping gneeration");
|
||||
log_print("$thumbnail_file exists, skipping generation");
|
||||
goto return_thumbnail;
|
||||
}
|
||||
|
||||
@ -108,5 +108,6 @@ function is_image_file_type(string $filename): bool {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
?>
|
||||
|
||||
main();
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user