diff options
| author | ilotterytea <iltsu@alright.party> | 2025-05-12 14:09:40 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-05-12 14:09:40 +0500 |
| commit | 6e5481c5d6cc3cc562cc3674b95dacbcb88372d7 (patch) | |
| tree | 436a7115c077cbfe7111635fb06314bda951ba6b /public | |
| parent | 952058eed3a6e8d3eb04dc8795e647ef4f655306 (diff) | |
feat: create image bundles for avatars and banners
Diffstat (limited to 'public')
| -rw-r--r-- | public/account/index.php | 24 | ||||
| -rw-r--r-- | public/users.php | 11 |
2 files changed, 14 insertions, 21 deletions
diff --git a/public/account/index.php b/public/account/index.php index 6e7dd33..d62f87f 100644 --- a/public/account/index.php +++ b/public/account/index.php @@ -39,17 +39,13 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if (isset($_FILES["pfp"]) && !empty($_FILES["pfp"]["tmp_name"])) { $pfp = $_FILES["pfp"]; - if (!is_dir("../static/userdata/avatars")) { - mkdir("../static/userdata/avatars", 0777, true); - } - if ( - $err = resize_image( + $err = create_image_bundle( $pfp["tmp_name"], $_SERVER["DOCUMENT_ROOT"] . "/static/userdata/avatars/" . $_SESSION["user_id"], ACCOUNT_PFP_MAX_SIZE[0], ACCOUNT_PFP_MAX_SIZE[1], - false, + true, true ) ) { @@ -61,17 +57,13 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if (isset($_FILES["banner"]) && !empty($_FILES["banner"]["tmp_name"])) { $banner = $_FILES["banner"]; - if (!is_dir("../static/userdata/banners")) { - mkdir("../static/userdata/banners", 0777, true); - } - if ( - $err = resize_image( + $err = create_image_bundle( $banner["tmp_name"], $_SERVER["DOCUMENT_ROOT"] . "/static/userdata/banners/" . $_SESSION["user_id"], ACCOUNT_BANNER_MAX_SIZE[0], ACCOUNT_BANNER_MAX_SIZE[1], - false, + true, true ) ) { @@ -109,8 +101,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { <h2>Profile</h2> <h3>Profile picture</h3> <?php - if (is_file("../static/userdata/avatars/" . $_SESSION["user_id"])) { - echo '<img src="/static/userdata/avatars/' . $_SESSION["user_id"] . '" id="pfp" width="64" height="64">'; + if (is_dir("../static/userdata/avatars/" . $_SESSION["user_id"])) { + echo '<img src="/static/userdata/avatars/' . $_SESSION["user_id"] . '/2x.webp" id="pfp" width="64" height="64">'; } else { echo "<p>You don't have profile picture</p>"; } @@ -119,8 +111,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { <h3>Profile banner</h3> <?php - if (is_file("../static/userdata/banners/" . $_SESSION["user_id"])) { - echo '<img src="/static/userdata/banners/' . $_SESSION["user_id"] . '" id="banner" width="192" height="108">'; + if (is_dir("../static/userdata/banners/" . $_SESSION["user_id"])) { + echo '<img src="/static/userdata/banners/' . $_SESSION["user_id"] . '/2x.webp" id="banner" width="256">'; } else { echo "<p>You don't have profile banner</p>"; } diff --git a/public/users.php b/public/users.php index 3320451..fced3eb 100644 --- a/public/users.php +++ b/public/users.php @@ -93,8 +93,8 @@ if ($id == "" && $alias_id == "") { echo '<tr><td>'; echo '<img src="/static/'; - if (is_file("static/userdata/avatars/" . $row["id"])) { - echo 'userdata/avatars/' . $row["id"]; + if (is_dir("static/userdata/avatars/" . $row["id"])) { + echo 'userdata/avatars/' . $row["id"] . '/1x.webp'; } else { echo 'img/defaults/profile_picture.png'; } @@ -315,7 +315,8 @@ if ($is_json) { </head> <body> - <div class="background" style="background-image: url('/static/userdata/banners/<?php echo $user->id() ?>');"> + <div class="background" + style="background-image: url('/static/userdata/banners/<?php echo $user->id() ?>/3x.webp');"> <div class="background-layer"></div> </div> @@ -332,8 +333,8 @@ if ($is_json) { <div class="box content justify-center items-center"> <?php echo '<img src="/static/'; - if (is_file("static/userdata/avatars/" . $user->id())) { - echo 'userdata/avatars/' . $user->id(); + if (is_dir("static/userdata/avatars/" . $user->id())) { + echo 'userdata/avatars/' . $user->id() . '/3x.webp'; } else { echo 'img/defaults/profile_picture.png'; } |
