Skip to content

Commit

Permalink
feat: auto scan dir for cover
Browse files Browse the repository at this point in the history
  • Loading branch information
KawaiiZapic committed Apr 19, 2024
1 parent fbaa588 commit c2ae578
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 1 deletion.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
7 changes: 6 additions & 1 deletion src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ static function Gravatar(string $mail,int $size = 40): void {

static function cover(Archive $archive): void {
if (!$archive->fields->cover) {
self::assets("assets/images/" . $archive->cid % 6 . ".png");
$covers = array_values(array_filter(scandir(__DIR__."/assets/covers"), function($c) {
return $c != "." && $c != "..";
}));
if (!$covers) return;
$count = count($covers);
self::assets("assets/covers/" . $covers[$archive->cid % $count]);
} else {
echo $archive->fields->cover;
}
Expand Down

0 comments on commit c2ae578

Please sign in to comment.