aboutsummaryrefslogtreecommitdiff
path: root/templates
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
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')
-rw-r--r--templates/single.inc.php9
-rw-r--r--templates/timeline.inc.php8
2 files changed, 8 insertions, 9 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
diff --git a/templates/timeline.inc.php b/templates/timeline.inc.php
index 6dd37c1..d07776d 100644
--- a/templates/timeline.inc.php
+++ b/templates/timeline.inc.php
@@ -52,14 +52,14 @@
</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']])): ?>
<?php
- $attachments_total = count($attachments);
+ $attachments_total = count($attachments[$post['id']]);
// only display the first attachment on the timeline
- array_splice($attachments, 1);
+ array_splice($attachments[$post['id']], 1);
?>
<ul class="post-attachments">
- <?php foreach($attachments as $a): ?>
+ <?php foreach($attachments[$post['id']] as $a): ?>
<li title="<?= ($attachments_total > 1) ? 'and '.($attachments_total-1).' more' : '' ?>">
<?php if(strpos($a['file_mime_type'], 'image') === 0): ?>
<?php