aboutsummaryrefslogtreecommitdiff
path: root/templates/single.inc.php
diff options
context:
space:
mode:
authorArno Richter <oelna@oelna.de>2023-01-13 14:32:18 +0100
committerArno Richter <oelna@oelna.de>2023-01-13 14:32:18 +0100
commitb20cf03c18ad06a5d9df4fa7bc61734fc57ba41b (patch)
treeccfff72643c3a3fd2831a8884618634a7fb5ec6c /templates/single.inc.php
parent04bffab6639fb3678ccb043b6e17e957d1ea662e (diff)
downloadmicroblog-b20cf03c18ad06a5d9df4fa7bc61734fc57ba41b.tar.gz
microblog-b20cf03c18ad06a5d9df4fa7bc61734fc57ba41b.tar.bz2
microblog-b20cf03c18ad06a5d9df4fa7bc61734fc57ba41b.zip
more efficient attachment retrival from DB for timeline rendering.
Diffstat (limited to 'templates/single.inc.php')
-rw-r--r--templates/single.inc.php9
1 files changed, 4 insertions, 5 deletions
diff --git a/templates/single.inc.php b/templates/single.inc.php
index 64e7f6d..5514742 100644
--- a/templates/single.inc.php
+++ b/templates/single.inc.php
@@ -109,8 +109,8 @@
<?php
$attachments = db_get_attached_files($post['id']);
?>
- <?php if(!empty($attachments)): ?>
- <?php foreach($attachments as $a): ?>
+ <?php if(!empty($attachments) && !empty($attachments[$post['id']])): ?>
+ <?php foreach($attachments[$post['id']] as $a): ?>
<?php if(strpos($a['file_mime_type'], 'image') === 0): ?>
<?php
$abs = ROOT.DS.get_file_path($a);
@@ -142,7 +142,6 @@
$formatted_time = date_format($date, 'M d Y H:i');
$attachments = db_get_attached_files($post['id']);
- // var_dump($attachments);
?>
<span class="post-timestamp">
<time class="published" datetime="<?= $datetime ?>" data-unix-time="<?= $post['post_timestamp'] ?>"><?= $formatted_time ?></time>
@@ -161,9 +160,9 @@
</ul><?php endif; ?>
</nav>
<div class="post-content"><?= nl2br(autolink($post['post_content'])) ?></div>
- <?php if(!empty($attachments)): ?>
+ <?php if(!empty($attachments) && !empty($attachments[$post['id']])): ?>
<ul class="post-attachments">
- <?php foreach($attachments as $a): ?>
+ <?php foreach($attachments[$post['id']] as $a): ?>
<li>
<?php if(strpos($a['file_mime_type'], 'image') === 0): ?>
<?php