summaryrefslogtreecommitdiff
path: root/src/emote.php
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-05-03 16:50:50 +0500
committerilotterytea <iltsu@alright.party>2025-05-03 16:50:50 +0500
commit2c51a000a9f2f51f54b761e4975086f9db3780a4 (patch)
tree6fbe2871a652cf3264cfd42fede1d6369cefca84 /src/emote.php
parenta196b0bdf3d7dd4a86c4bf0bc5d5065ac03cd268 (diff)
upd: big changes in database.sql + .webp is now default image format
Diffstat (limited to 'src/emote.php')
-rw-r--r--src/emote.php15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/emote.php b/src/emote.php
index 769d62a..ea9e52c 100644
--- a/src/emote.php
+++ b/src/emote.php
@@ -65,7 +65,7 @@ class Emote
function html_random_emote(PDO &$db)
{
- $stmt = $db->prepare("SELECT id, ext, code FROM emotes WHERE visibility = 1 AND is_featured = false ORDER BY RAND() LIMIT 1");
+ $stmt = $db->prepare("SELECT id, code FROM emotes WHERE visibility = 1 ORDER BY RAND() LIMIT 1");
$stmt->execute();
if ($row = $stmt->fetch()) {
@@ -77,8 +77,8 @@ function html_random_emote(PDO &$db)
</div>
<div class="box content center">
<a href="/emotes?id=<?php echo $row["id"] ?>">
- <img src="/static/userdata/emotes/<?php echo $row["id"] . '/3x.' . $row["ext"] ?>"
- alt="<?php echo $row["code"] ?>" width="192">
+ <img src="/static/userdata/emotes/<?php echo $row["id"] ?>/3x.webp" alt="<?php echo $row["code"] ?>"
+ width="192">
</a>
</div>
</section>
@@ -89,7 +89,10 @@ function html_random_emote(PDO &$db)
function html_featured_emote(PDO &$db)
{
- $stmt = $db->prepare("SELECT id, ext, code FROM emotes WHERE visibility = 1 AND is_featured = true ORDER BY updated_at DESC LIMIT 1");
+ $stmt = $db->prepare("SELECT e.id, e.code FROM emotes e
+ INNER JOIN emote_sets es ON es.is_featured = TRUE
+ INNER JOIN emote_set_contents esc ON es.id = esc.emote_set_id
+ WHERE e.visibility = 1 AND e.id = esc.emote_id ORDER BY esc.added_at DESC LIMIT 1");
$stmt->execute();
if ($row = $stmt->fetch()) {
@@ -101,8 +104,8 @@ function html_featured_emote(PDO &$db)
</div>
<div class="box content center">
<a href="/emotes?id=<?php echo $row["id"] ?>">
- <img src="/static/userdata/emotes/<?php echo $row["id"] . '/3x.' . $row["ext"] ?>"
- alt="<?php echo $row["code"] ?>" width="192">
+ <img src="/static/userdata/emotes/<?php echo $row["id"] ?>/3x.webp" alt="<?php echo $row["code"] ?>"
+ width="192">
</a>
</div>
</section>