From 6e5481c5d6cc3cc562cc3674b95dacbcb88372d7 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Mon, 12 May 2025 14:09:40 +0500 Subject: feat: create image bundles for avatars and banners --- public/account/index.php | 24 ++++++++---------------- public/users.php | 11 ++++++----- 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") {

Profile

Profile picture

'; + if (is_dir("../static/userdata/avatars/" . $_SESSION["user_id"])) { + echo ''; } else { echo "

You don't have profile picture

"; } @@ -119,8 +111,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {

Profile banner

'; + if (is_dir("../static/userdata/banners/" . $_SESSION["user_id"])) { + echo ''; } else { echo "

You don't have profile banner

"; } 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 ''; echo ' -
+
@@ -332,8 +333,8 @@ if ($is_json) {
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