diff options
author | Freya Murphy <freya@freyacat.org> | 2024-04-05 10:46:09 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-04-05 10:46:09 -0400 |
commit | 530bbf058781e00e588f1457b6ee589a64b74da1 (patch) | |
tree | c6cdd382a86d55538686293e51a1fc056cb59029 /src/web/helper | |
parent | remove var (diff) | |
download | xssbook2-530bbf058781e00e588f1457b6ee589a64b74da1.tar.gz xssbook2-530bbf058781e00e588f1457b6ee589a64b74da1.tar.bz2 xssbook2-530bbf058781e00e588f1457b6ee589a64b74da1.zip |
i did thing oh god large commit
Diffstat (limited to 'src/web/helper')
-rw-r--r-- | src/web/helper/image.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/web/helper/image.php b/src/web/helper/image.php new file mode 100644 index 0000000..ac2f808 --- /dev/null +++ b/src/web/helper/image.php @@ -0,0 +1,33 @@ +<?php /* Copyright (c) 2024 Freya Murphy */ + +function image($src, $class = NULL, $link = NULL): string { + if ($class) { + $class = 'image-loading ' . $class; + } else { + $class = 'image-loading'; + } + + $content = ''; + + if ($link) { + $content .= '<a class="' . $class . '" href="' . $link . '">'; + } else { + $content .= '<span class="' . $class . '">'; + } + $content .= '<img src="' . $src . '" onerror="onImgError(this)" onload="onImgLoad(this)"/>'; + if ($link) { + $content .= '</a>'; + } else { + $content .= '</span>'; + } + + return $content; +} + +function pfp( + $user, + $embedLink = TRUE, +): string { + $link = $embedLink ? '/profile?id=' . $user['id'] : NULL; + return image('/api/rpc/profile_avatar?user_id=' . $user['id'], 'pfp', link: $link); +} |