Merge pull request #12614 from haheute/photo-view-direction

improve previous / next function in photo gallery
This commit is contained in:
Hypolite Petovan 2023-01-04 11:45:12 -05:00 committed by GitHub
commit 489e04e666
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -937,11 +937,17 @@ function photos_content(App $a)
$nxt = null;
foreach ($prvnxt as $z => $entry) {
if ($entry['resource-id'] == $ph[0]['resource-id']) {
$prv = $z - 1;
$nxt = $z + 1;
$prv = $order_field === 'created' ? $z - 1 : $z + 1;
$nxt = $order_field === 'created' ? $z + 1 : $z - 1;
if ($prv < 0) {
$prv = count($prvnxt) - 1;
}
if ($nxt < 0) {
$nxt = count($prvnxt) - 1;
}
if ($prv >= count($prvnxt)) {
$prv = 0;
}
if ($nxt >= count($prvnxt)) {
$nxt = 0;
}