diff options
| author | ilotterytea <iltsu@alright.party> | 2025-05-07 14:42:30 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-05-07 14:42:30 +0500 |
| commit | d857bf78c0f8639eae9e21ffe4e04ee68e94d04b (patch) | |
| tree | 2cecbfa99e3ac428d7e4537a14bda0682dee3e5d /public/users.php | |
| parent | ff7178fd42240cb1ad012c6afd11f40020963f53 (diff) | |
feat: display default avatar if user doesn't have one
Diffstat (limited to 'public/users.php')
| -rw-r--r-- | public/users.php | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/public/users.php b/public/users.php index 933ada4..f1aa3e7 100644 --- a/public/users.php +++ b/public/users.php @@ -86,9 +86,15 @@ if ($id == "" && $alias_id == "") { $last_active = format_timestamp($diff); } - echo '<tr>'; - echo '<td><img src="/static/userdata/avatars/' . $row["id"] . '" width="24" height="24"></td>'; - echo '<td><a href="/users.php?id=' . $row["id"] . '">' . $row["username"] . '</a></td>'; + echo '<tr><td>'; + echo '<img src="/static/'; + if (is_file("static/userdata/avatars/" . $row["id"])) { + echo 'userdata/avatars/' . $row["id"]; + } else { + echo 'img/defaults/profile_picture.png'; + } + echo '" width="24" height="24">'; + echo '</td><td><a href="/users.php?id=' . $row["id"] . '">' . $row["username"] . '</a></td>'; echo "<td>$last_active ago</td>"; echo '</tr>'; } @@ -322,13 +328,28 @@ if ($is_json) { <section class="user-bar column small-gap"> <section class="box"> <div class="box navtab"> - <p>User #<?php echo $user->id() ?></p> - </div> - <div class="box content background" - style="background-image: url('/static/userdata/banners/<?php echo $user->id() ?>');"> - <img src="/static/userdata/avatars/<?php echo $user->id() ?>" width="96" height="96"> - <h1><?php echo $user->username() ?></h1> + <p>User</p> </div> + <?php + echo '<div class="box content background"'; + + if (is_file("static/userdata/banners/" . $user->id())) { + echo ' style="background-image: url(\'/static/userdata/banners/' . $user->id() . '\');">'; + } else { + echo '>'; + } + + echo '<img src="/static/'; + if (is_file("static/userdata/avatars/" . $user->id())) { + echo 'userdata/avatars/' . $user->id(); + } else { + echo 'img/defaults/profile_picture.png'; + } + echo '" width="96" height="96">'; + echo '<h1>' . $user->username() . '</h1>'; + + echo '</div>'; + ?> </section> <!-- STATS --> |
