summaryrefslogtreecommitdiff
path: root/src/web/helper
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/helper')
-rw-r--r--src/web/helper/image.php15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/web/helper/image.php b/src/web/helper/image.php
index ac2f808..8815a6c 100644
--- a/src/web/helper/image.php
+++ b/src/web/helper/image.php
@@ -1,6 +1,6 @@
<?php /* Copyright (c) 2024 Freya Murphy */
-function image($src, $class = NULL, $link = NULL): string {
+function image($src, $class = NULL, $link = NULL, $click = NULL): string {
if ($class) {
$class = 'image-loading ' . $class;
} else {
@@ -11,12 +11,16 @@ function image($src, $class = NULL, $link = NULL): string {
if ($link) {
$content .= '<a class="' . $class . '" href="' . $link . '">';
+ } else if ($click) {
+ $content .= '<button class="' . $class . '" onclick="' . $click . '">';
} else {
$content .= '<span class="' . $class . '">';
}
$content .= '<img src="' . $src . '" onerror="onImgError(this)" onload="onImgLoad(this)"/>';
if ($link) {
$content .= '</a>';
+ } else if ($click) {
+ $content .= '</button>';
} else {
$content .= '</span>';
}
@@ -26,8 +30,11 @@ function image($src, $class = NULL, $link = NULL): string {
function pfp(
$user,
- $embedLink = TRUE,
+ $link = TRUE,
+ $click = NULL
): string {
- $link = $embedLink ? '/profile?id=' . $user['id'] : NULL;
- return image('/api/rpc/profile_avatar?user_id=' . $user['id'], 'pfp', link: $link);
+ if ($link === TRUE) {
+ $link = '/profile?id=' . $user['id'];
+ }
+ return image('/api/rpc/profile_avatar?user_id=' . $user['id'], 'pfp', link: $link, click: $click);
}