Best practices for inserting gallery folders?

In my theme design, I want to insert a path, such as assets/gallery/cat, and automatically load all the cute cat pictures from the cat folder.

I’ve tried some ideas, and strangely, it worked successfully on my local Windows deployment, but when pushed to the Vercel server, it didn’t work. It seems the directory or corresponding files couldn’t be found.

I think this might be a common requirement for gallery functionality — simply placing images in a specific folder without needing much configuration. So I’d like to ask if there are any best practices for this, or if there’s some reference code snippet. Thanks!

We’ll need some more information to answer your question.

In the interim, look at the capitalization of your file names and directories. Windows is case insensitive, Linux is not.

Thank you for your suggestion. I switched to using readDir to index file paths, and converted everything to lowercase to match the titles consistently. In any case, although I’m not sure which part was the key, the issue is resolved. Thank you! I’m working on a waterfall layout theme, and now the gallery mode works. Thanks again!

Yeah, you really don’t want to do that. The os.ReadDir function doesn’t work with mounts.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.