hic-et-nunc/site/controllers/home.php
isUnknown 4490e11794 home > slideshow : skip desktop-only slides on mobile (< 1000px)
Closes #8

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-05 18:40:31 +02:00

33 lines
900 B
PHP

<?php
return function($site) {
$files = $site->slideshow()->toFiles();
$count = $files->count();
$units = [];
$i = 0;
while ($i < $count) {
$file = $files->nth($i);
$nextFile = $files->nth($i + 1);
$isPortrait = $file->type() === 'image' && $file->orientation() === 'portrait';
$nextIsPortrait = $nextFile && $nextFile->type() === 'image' && $nextFile->orientation() === 'portrait';
if ($isPortrait && $nextIsPortrait) {
$units[] = ['pair' => true, 'a' => $file, 'b' => $nextFile];
$i += 2;
} else {
$units[] = ['pair' => false, 'file' => $file, 'isHiddenOnMobile' => (bool) $file->isHiddenOnMobile()->isTrue()];
$i++;
}
}
if ($site->areSlidesShuffled()->isTrue()) {
shuffle($units);
}
return [
'slides' => $units,
];
};