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

ER: Manual sort order #34

Open
lewisthompson opened this issue Jan 16, 2022 · 3 comments
Open

ER: Manual sort order #34

lewisthompson opened this issue Jan 16, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@lewisthompson
Copy link

lewisthompson commented Jan 16, 2022

This plugin looks great. I'd like to migrate from https://github.com/liwenyip/hugo-easy-gallery/ but the missing feature for me is the ability to specify a custom image order without relying on file naming.

@mfg92 mfg92 added the enhancement New feature or request label Jan 16, 2022
@mfg92
Copy link
Owner

mfg92 commented Jan 16, 2022

One solution for your issue would be to implement sorting by any value found in exif or in the sidecar file (https://github.com/mfg92/hugo-shortcode-gallery#sidecar-files). Then one could add a value order to the sidecar file and use that for sorting.

@ianspray
Copy link

I wanted to get the images sorted by EXIF Date order, so changed the layouts/shortcode/gallery.html file (line 89) from:

{{ range $original := sort $images "Name" $sortOrder}}

to :

{{ range $original := sort $images "Exif.Date" $sortOrder}}

which failed when it hit the .meta files as they had no EXIF data (as the test for the file being an image is done after the list is read via range). Moving all metadata files into a subdir within images (ie: images/meta) and updating the path to read the metadata from (line 93):

{{ $metaFileName := print "meta/" $original.Name ".meta"}}

does allow the image list to be built with the correct order, and with the metadata merged as expected when viewing the final index.html file source code, but for some reason it doesn't load the images when viewing in my browser.

My hugo skills are around 24hrs old, so I will keep working on this, but wanted to offer up this partial solution for discussion. If it's heading in the right direction then then fix for the user-facing sort aspect may be as simple as placing the current "Name" into a variable, and then it can be swapped directly for Exif.Date or any other built-in function.

@ianspray
Copy link

ianspray commented Feb 21, 2022

Right: images sorted by EXIF Date do work - I had my meta path incorrect, and for the code fragment above it should look like this:

gallery
├── images
│   ├── image001.jpg
│   ├── image002.jpg
│   └── image003.jpg
├── index.md
└── meta
    └── images
        ├── image001.jpg.meta
        ├── image002.jpg.meta
        └── image003.jpg.meta

Obviously, that sucks as a layout !

An interesting side note: the 'vanishing' images were down to me having the filterOptions declared, but the metadata not being scanned: in this case the images flashed up and then vanished, with just the filter buttons in view.

I'm not sure if that's something worth noting, or if it falls into the "if you do bad things, other bad things happen", but it may be worth having an FAQ/Debug entry saying that if the images don't appear, remove the filterOptions and see if they come back again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants