feat(artists): change albums table to grid on artist pages

This commit is contained in:
Cory Dransfeldt 2025-05-24 13:28:04 -07:00
parent 80b0499550
commit 9b4baad5fb
No known key found for this signature in database
14 changed files with 180 additions and 88 deletions

View file

@ -1,5 +1,57 @@
<?php
function renderMediaGrid(array $items, string $cdnUrl, string $shape = 'square', int $count = 0, string $loading = 'lazy') {
$imageClass = 'square';
$width = 150;
$height = 150;
if ($shape === 'vertical') {
$imageClass = 'vertical';
$width = 120;
$height = 184;
}
$limit = $count > 0 ? $count : count($items);
echo '<div class="media-grid ' . htmlspecialchars($shape) . '">';
foreach (array_slice($items, 0, $limit) as $item) {
$grid = $item['grid'] ?? $item;
$alt = htmlspecialchars($grid['alt'] ?? '');
$image = htmlspecialchars($grid['image'] ?? '');
$title = htmlspecialchars($grid['title'] ?? '');
$subtext = htmlspecialchars($grid['subtext'] ?? '');
$url = $grid['url'] ?? null;
$openLink = $url ? '<a href="' . htmlspecialchars($url) . '" title="' . $alt . '">' : '';
$closeLink = $url ? '</a>' : '';
echo $openLink;
echo '<div class="media-grid-item">';
if ($title || $subtext) {
echo '<div class="meta-text media-highlight">';
if ($title) echo '<div class="header">' . $title . '</div>';
if ($subtext) echo '<div class="subheader">' . $subtext . '</div>';
echo '</div>';
}
echo '<img
srcset="' . $cdnUrl . $image . '?class=' . $imageClass . 'sm&type=webp ' . $width . 'w, ' .
$cdnUrl . $image . '?class=' . $imageClass . 'md&type=webp ' . ($width * 2) . 'w"
sizes="(max-width: 450px) ' . $width . 'px, ' . ($width * 2) . 'px"
src="' . $cdnUrl . $image . '?class=' . $imageClass . 'sm&type=webp"
alt="' . $alt . '"
loading="' . $loading . '"
decoding="async"
width="' . $width . '"
height="' . $height . '"
/>';
echo '</div>';
echo $closeLink;
}
echo '</div>';
}
function renderAssociatedMedia($artists = [], $books = [], $genres = [], $movies = [], $posts = [], $shows = [])
{
$media = array_merge($artists, $books, $genres, $movies, $posts, $shows);