Allow clicking through to full quality images master
authorJacob Casper <dev@jacobcasper.com>
Sun, 26 Jun 2022 21:17:18 +0000 (16:17 -0500)
committerJacob Casper <dev@jacobcasper.com>
Sun, 26 Jun 2022 21:17:18 +0000 (16:17 -0500)
app.php

diff --git a/app.php b/app.php
index a3f2597..06d5ff0 100644 (file)
--- a/app.php
+++ b/app.php
@@ -13,7 +13,12 @@ require_once __DIR__ . '/db.php';
 
 $db = get_db();
 $posts = $db->query('SELECT
-  p.ID, p.TIMESTAMP, pi.MIME_TYPE, pi.PIC_B64, c.BODY
+  p.ID as POST_ID,
+  p.TIMESTAMP,
+  pi.ID as PIC_ID,
+  pi.MIME_TYPE,
+  pi.PIC_B64,
+  c.BODY
   FROM posts p
   JOIN pics pi on p.id = pi.post_id
   JOIN comments c on p.id = c.post_id
@@ -21,7 +26,8 @@ $posts = $db->query('SELECT
 while ($post = $posts->fetchArray()) {
   $mime_type = $post['MIME_TYPE'];
   $file_b64 = $post['PIC_B64'];
-  $post_id = $post['ID'];
+  $post_id = $post['POST_ID'];
+  $pic_id = $post['PIC_ID'];
   $comment_text = $post['BODY'];
   $img = new Imagick();
   $img->readImageBlob(base64_decode($file_b64));
@@ -31,7 +37,7 @@ while ($post = $posts->fetchArray()) {
 
   echo "<div id='post-{$post_id}'>";
 
-  echo "<img src='data:{$mime_type};base64,{$compressed_b64}' alt='$'/>";
+  echo "<a href='pic/{$pic_id}'> <img src='data:{$mime_type};base64,{$compressed_b64}' alt='$'/></a>";
   echo "<p>{$comment_text}</p>";
   echo '</div>';
 }