hic-et-nunc/site/controllers/home.php
Camilledenoray c6ca1edc36
All checks were successful
Deploy / Deploy to Production (push) Successful in 8s
mobile > index > project selected > Fixed: projects disapearing when hover on fix
2026-07-08 14:56:34 +02:00

35 lines
977 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 = in_array($file->type(), ['image', 'video'], true)
&& $file->fileOrientation() === 'portrait';
$nextIsPortrait = $nextFile
&& in_array($nextFile->type(), ['image', 'video'], true) && $nextFile->fileOrientation() === '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,
];
};