fix(associated-media): sorts + grid sizing

This commit is contained in:
Cory Dransfeldt 2025-05-24 18:49:25 -07:00
parent 6a41304b5f
commit 3dac23b171
No known key found for this signature in database
9 changed files with 116 additions and 61 deletions

View file

@ -2,8 +2,11 @@
function renderMediaGrid(array $items, int $count = 0, string $loading = 'lazy') {
$limit = $count > 0 ? $count : count($items);
$firstType = $items[0]['type'] ?? ($items[0]['grid']['type'] ?? '');
$shapeClass = in_array($firstType, ['books', 'movies', 'tv']) ? 'vertical' : 'square';
echo '<div class="media-grid ' . $shapeClass . '">';
echo '<div class="media-grid">';
foreach (array_slice($items, 0, $limit) as $item) {
$grid = $item['grid'] ?? $item;
$alt = htmlspecialchars($grid['alt'] ?? '');
@ -12,7 +15,7 @@
$subtext = htmlspecialchars($grid['subtext'] ?? '');
$url = $grid['url'] ?? null;
$type = $item['type'] ?? '';
$isVertical = in_array($type, ['books', 'movies', 'shows']);
$isVertical = in_array($type, ['books', 'movies', 'tv']);
$imageClass = $isVertical ? 'vertical' : 'square';
$width = $isVertical ? 120 : 150;
$height = $isVertical ? 184 : 150;
@ -44,6 +47,7 @@
echo '</div>';
echo $closeLink;
}
echo '</div>';
}