aboutsummaryrefslogtreecommitdiff
path: root/templates/timeline.inc.php
diff options
context:
space:
mode:
authorArno Richter <oelna@oelna.de>2022-12-21 15:05:28 +0100
committerArno Richter <oelna@oelna.de>2022-12-21 15:05:28 +0100
commit482fd7adee5e9e0990bf5904ed7d754d315de649 (patch)
tree7523a6f3482b6cb024624310f21fa7eeb05e9866 /templates/timeline.inc.php
parent057cace8b32e6c3d105695b517eae262071601f4 (diff)
downloadmicroblog-482fd7adee5e9e0990bf5904ed7d754d315de649.tar.gz
microblog-482fd7adee5e9e0990bf5904ed7d754d315de649.tar.bz2
microblog-482fd7adee5e9e0990bf5904ed7d754d315de649.zip
first attempt at image attachments!
Diffstat (limited to 'templates/timeline.inc.php')
-rw-r--r--templates/timeline.inc.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/templates/timeline.inc.php b/templates/timeline.inc.php
index bc06de9..6dd37c1 100644
--- a/templates/timeline.inc.php
+++ b/templates/timeline.inc.php
@@ -36,6 +36,8 @@
$datetime = date_format($date, 'Y-m-d H:i:s');
$formatted_time = date_format($date, 'M d Y H:i');
+
+ $attachments = db_get_attached_files($post['id']);
?>
<a class="post-timestamp" href="<?= $config['url'] ?>/<?= $post['id'] ?>">
<time class="published" datetime="<?= $datetime ?>" data-unix-time="<?= $post['post_timestamp'] ?>"><?= $formatted_time ?></time>
@@ -50,6 +52,34 @@
</ul><?php endif; ?>
</nav>
<div class="post-content"><?= nl2br(autolink($post['post_content'])) ?></div>
+ <?php if(!empty($attachments)): ?>
+ <?php
+ $attachments_total = count($attachments);
+ // only display the first attachment on the timeline
+ array_splice($attachments, 1);
+ ?>
+ <ul class="post-attachments">
+ <?php foreach($attachments as $a): ?>
+ <li title="<?= ($attachments_total > 1) ? 'and '.($attachments_total-1).' more' : '' ?>">
+ <?php if(strpos($a['file_mime_type'], 'image') === 0): ?>
+ <?php
+ $abs = ROOT.DS.get_file_path($a);
+ list($width, $height, $_, $size_string) = getimagesize($abs);
+ $url = $config['url'] .'/'. get_file_path($a);
+ ?>
+ <a href="<?= $config['url'] ?>/<?= $post['id'] ?>">
+ <picture>
+ <source srcset="<?= $url ?>" type="image/jpeg" />
+ <img src="<?= $url ?>" alt="<?= $a['file_original'] ?>" <?= $size_string ?> loading="lazy" />
+ </picture>
+ </a>
+ <?php else: ?>
+ <a href="<?= $url ?>" download="<?= $a['file_original'] ?>"><?= $a['file_original'] ?></a>
+ <?php endif; ?>
+ </li>
+ <?php endforeach; ?>
+ </ul>
+ <?php endif; ?>
</li>
<?php endforeach; ?>
</ul>