33 lines
900 B
PHP
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,
|
|
];
|
|
};
|