diff options
| -rw-r--r-- | public/account/index.php | 24 | ||||
| -rw-r--r-- | public/users.php | 11 | ||||
| -rw-r--r-- | src/partials.php | 4 |
3 files changed, 16 insertions, 23 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'; } diff --git a/src/partials.php b/src/partials.php index a361f7b..c9ee5cb 100644 --- a/src/partials.php +++ b/src/partials.php @@ -83,8 +83,8 @@ function html_navigation_bar() Signed in as <?php echo $_SESSION["user_name"] ?> <?php echo '<img src="/static/'; - if (is_file($_SERVER['DOCUMENT_ROOT'] . "/static/userdata/avatars/" . $_SESSION["user_id"])) { - echo 'userdata/avatars/' . $_SESSION["user_id"]; + if (is_dir($_SERVER['DOCUMENT_ROOT'] . "/static/userdata/avatars/" . $_SESSION["user_id"])) { + echo 'userdata/avatars/' . $_SESSION["user_id"] . "/1x.webp"; } else { echo 'img/defaults/profile_picture.png'; } |
