Files
tsv08kulmbach-website/app/components/instagram-feed.php

42 lines
2.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
/**
* "Aktuelles": Instagram-Grid aus dem lokalen Cache (data/instagram.json,
* geschrieben von bin/instagram-sync.php). Besucher laden ausschließlich
* lokal gehostete Bilder. Ohne Cache: CTA-Karte als Degradation.
*/
$club = json_load('club');
$feed = json_load('instagram');
$posts = $feed['posts'] ?? [];
$maxPosts = (int) config('instagram.max_posts', 9);
?>
<section class="section instagram" id="aktuelles">
<div class="container">
<h2>Aktuelles aus dem Fußball</h2>
<?php if ($posts !== []): ?>
<p class="text-muted">Unsere neuesten Beiträge auf <a href="<?= e($club['social']['instagram']) ?>" rel="noopener">Instagram (@<?= e($feed['username'] ?? 'tsv08kulmbach') ?>)</a><?php if (!empty($club['social']['facebook'])): ?> folge uns auch auf <a href="<?= e($club['social']['facebook']) ?>" rel="noopener">Facebook</a><?php endif; ?>.</p>
<ul class="instagram__grid">
<?php foreach (array_slice($posts, 0, $maxPosts) as $post): ?>
<li class="instagram__item">
<a class="instagram__link" href="<?= e($post['url']) ?>" rel="noopener">
<img src="<?= e(asset($post['image'])) ?>"
alt="<?= e($post['alt'] ?? 'Instagram-Beitrag des TSV 08 Kulmbach') ?>"
width="640" height="800" loading="lazy" decoding="async">
<?php if (!empty($post['is_video'])): ?>
<span class="instagram__badge" aria-hidden="true">▶</span>
<?php endif; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<div class="instagram__fallback">
<p>Was bei uns gerade los ist, siehst du auf unserem Instagram-Kanal.</p>
<p><a class="btn" href="<?= e($club['social']['instagram']) ?>" rel="noopener">Folge uns auf Instagram</a></p>
</div>
<?php endif; ?>
</div>
</section>