summaryrefslogtreecommitdiff
path: root/src/web/helper/image.php
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-12-23 11:13:27 -0500
committerFreya Murphy <freya@freyacat.org>2024-12-23 11:13:27 -0500
commit5a2ba9c2e7605bb788bc406184547d22c6436867 (patch)
treecbd988d534e8a8593a31d70571222443f80da0b3 /src/web/helper/image.php
parentfix about modal (diff)
downloadxssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.tar.gz
xssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.tar.bz2
xssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.zip
v2.1.0, refactor w/ crimson
Diffstat (limited to 'src/web/helper/image.php')
-rw-r--r--src/web/helper/image.php77
1 files changed, 0 insertions, 77 deletions
diff --git a/src/web/helper/image.php b/src/web/helper/image.php
deleted file mode 100644
index 6d42678..0000000
--- a/src/web/helper/image.php
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php /* Copyright (c) 2024 Freya Murphy */
-
-function image(
- $src,
- $class = NULL,
- $link = NULL,
- $click = NULL,
- $height = NULL,
- $width = NULL,
- $mime = NULL,
-): string {
- if ($class) {
- $class = 'image loading ' . $class;
- } else {
- $class = 'image loading';
- }
-
- $content = '';
-
- // dont need mime for images
- if ($mime && strpos($mime, 'image') !== FALSE) {
- $mime = NULL;
- }
-
- if ($link) {
- $content .= '<a class="' . $class . '" href="' . $link . '">';
- } else if ($click) {
- $content .= '<button class="' . $class . '" onclick="' . $click . '">';
- } else {
- $content .= '<span class="' . $class . '">';
- }
- if ($mime) {
- $content .= '<object class="inner" type="' . $mime . '" data="' . $src . '" ';
- } else {
- $content .= '<img class="inner" src="' . $src . '" ';
- }
- if ($height) {
- $content .= "height=\"{$height}\" ";
- }
- if ($width) {
- $content .= "width=\"{$width}\" ";
- }
- if ($mime) {
- $content .= '></object>';
- } else {
- $content .= 'onerror="onImgError(this)" onload="onImgLoad(this)"/>';
- }
- if ($link) {
- $content .= '</a>';
- } else if ($click) {
- $content .= '</button>';
- } else {
- $content .= '</span>';
- }
-
- return $content;
-}
-
-function pfp(
- $user,
- $link = TRUE,
- $click = NULL
-): string {
- if ($link === TRUE) {
- $link = '/profile?id=' . $user['id'];
- }
- $mime = NULL;
- if (isset($user['avatar_mime'])) {
- $mime = $user['avatar_mime'];
- }
- return image('/api/rpc/profile_avatar?user_id=' . $user['id'],
- 'pfp',
- link: $link,
- click: $click,
- mime: $mime
- );
-}