Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Album ordering malfunctions when album is composed solely of more albums #52

Open
awong234 opened this issue Feb 5, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@awong234
Copy link

awong234 commented Feb 5, 2024

Problem

Album ordering is not as expected.

Issue

Albums that are composed solely of sub-albums (that is to say, the album does not have any direct image descendents) cannot extract a modification time, because it's expecting at least one image in the level below it.

Solution

Easiest way to get around this is just to keep at least one image in the album itself.

The logic for obtaining album $modDate should recursively access modification times to order albums if there do not exist any images in the level directly below it. I suspect it might be done here;

$orderedAlbums[$album] = '';

Instead of returning an empty string, it might dig down to the first album that has images as a direct descendant. I might work on this but again I'm not great at PHP so it would take me a little longer, and this seems like a relatively simple fix.

Details

I have debugged this issue by placing the following code in the nova-themes/novagallery/home.php file, around line 17:

<div class="col-12 col-sm-6 col-md-4 col-lg-3 mb-5 element">
  <a href="<?php echo Site::basePath().'/album/'.$elementPath; ?>">
    <img src="<?php echo Image::url($elementPath, $gallery->coverImage($element, $order), Site::config('imageSizeThumb')); ?>" loading="lazy" class="rounded"><br>
    <?php echo ucwords($element . " MOD: " . array_values($modDate)[0]); ?> <!-- <----------- added this line -->
  </a>
</div>

It displayed a missing $modDate for the out-of-order album:

image

I suspect when it goes to get array_values($images)[0], it is expecting that at least one of the values in the array is a timestamp. But if all the elements of the array are albums, then the value isn't a straight time-stamp value, it's a key-value array of more images. To test this theory, if I placed at least one image in the out-of-order album, then it should reflect a correct modification time -- and it does.

image

Notice the 2015 album now has a value for $modDate and is ordered correctly.

The logic here therefore should recursively access modification times to order albums if there do not exist any images in the level directly below it.

@david-novafacile
Copy link
Contributor

Thank you very much for the detailed bug research and for supporting novaGallery!

👍 👍

This should be fixed and is on the roadmap now!

@david-novafacile david-novafacile self-assigned this Feb 6, 2024
@david-novafacile david-novafacile added the bug Something isn't working label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants