Carl Sven
Carl Sven
Ministry of Information Technology

2025-04-15

Making Chris Kankiewicz's UberGallery Use One Theme Across Multiple Galleries

Web development post

Since we ditched WordPress to run a mostly-hand-coded website, I've had to rely on some PHP scripts to accomplish some things that otherwise would take way too long to create. One of these is photo galleries. After looking for a working PHP script that met all of my requirements of a photo gallery script for all of Kevin Tracy's incredible adventures, I stumbled upon Chris Kankiewicz's 2013 creation he called UberGallery. UberGallery let me easily fit it inside the theme of my website and the code was relatively simple to modify to make it work well on KTracy.com. If you're starting your own website and need a lightweight photo gallery, UberGallery is pretty great.

Multiple Galleries

There's just one problem. UberGallery is not UberGalleries. That is to say, UberGallery does not support multiple galleries. Instead, I had to upload a unique instance of UberGallery for every gallery I had and link to them from another page. It was a minor work around, but it accomplished what I set out to do. However, I still have not migrated KTracy.com away from BlueHost and, while Bluehost advertised unlimited file upload, that isn't actually true. Now, I was still nowhere near that limit, but the problem of file quantity recently appeared as a distant blip on my radar and I decided to address it by going after the worst offender: UberGallery.

Having multiple UberGallery instances causes several other problems in addition to just file quantity. Chief among these is load time and bandwidth. If a visitor comes and looks at two or more photo galleries, their browser has to pull and cache the entire UberGallery code and theme in each gallery. My solution to this would have to get rid of that.

There's another problem with running multiple galleries with UberGallery; which has bothered me since day one. It gets more difficult to change the theme across all of your galleries with each gallery you add. If I decide to get rid of the blue theme and go with red, or if 4K monitors become standard in a few years and I want larger thumbnails or more thumbnails in each gallery, I would have to change the theme in each and every gallery.

At the time of fixing this, I had 44 galleries uploaded on KTracy.com and the 45th gallery of Kevin Tracy's 2015 trip to Huntsville, AL and NASA Space Camp with all of the UberGallery code ready to be uploaded.

The Simple Improvement To Share A Theme Across Multiple UberGallery Galleries

Step 1: Create The Resources Directory Every Gallery Will Look For

My solution was to take the 'Resources' folder in one of the UberGallery folders and throw it in the directory directly above that... in this case, the directory that had all of my gallery folders.

So, I went from this:

To this... and yes, I changed the name of the folder from Resources to Theme because I wanted to and it makes more sense to me.

Step 2: Modify The index.php File in Each Gallery Folder

These resources are pulled directly in the index.php file in an open ended PHP tag. The first variable in that tag is what you're looking for. Here's what mine looks like now, but you'll want to change this to match whatever directory names you have leading to your theme:

    // Include the UberGallery class
    include($_SERVER['DOCUMENT_ROOT'].'/multimedia/kevin-tracy-museum/kevin-tracy-adventures/theme/UberGallery.php');
	

Step 3: Delete All Themes You're Not Using

UberGallery comes with several themes. For me, uber-blue worked REALLY well with a few changes to the Stylesheet. If you don't remember what theme you're using, it's in the galleryConfig.ini file in that Resources folder.

Look for something like: theme_name = uber-blue; Theme used to style the gallery

Anyways, I deleted this waste of disk space:

Step 4: Upload Your Files and Test It Out

Okay, you COULD skip this step, but do you really trust me? Some guy who writes mostly about politics, Catholicism, and art on the internet with your website? I sure didn't! Test this out on a single gallery and make sure it works for you before the next step.

Step 5: Replace Each Gallery's index.php to Point At The New Common Theme

Assuming you tested this in Step 4 and everything worked out, go ahead and replace all of your index.php files for each of your galleries.

Step 6: Delete Resources Folder In Each of Your Galleries

Okay, you probably could do this in Step 5, but I like batching things out all at the same time. It decreases the chances that I'll forget to replace an index.php or delete a directory.

Step 7: Enjoy your new galleries!

This might cause your galleries to regenerate all of your thumbnails. It might not be a bad idea to actually enjoy ALL of your galleries at least once before wrapping up.

How Big Was The Change?

Take a look for yourself:

BeforeAfter

So, it probably isn't worth noting, but the BEFORE does not include Gallery #45 but the AFTER does include Gallery #45. However, despite this, KTracy.com's disk usage dropped approximately 50MB. More importantly, there are 6,656 fewer files being used by KTracy.com after these changes.

More importantly, I now feel more confident about making changes to the theme of the photo galleries because I can change all of them at once. By simplifying the code, UberGallery is working so much better for my 45 photo galleries and growing.

A Special Thank You

I want to close this out by sending a special thank you to Chris Kankiewicz, the creator of UberGallery. UberGallery works shockingly well despite its age, and it's a testament to his talent as a programmer and him as a person for making this available to everyone for free. As someone who is pulling away from social media and advocating for personal websites without using WordPress or similar site builder tools, there are fewer and fewer web developers making PHP scripts like UberGallery for the public to use. Chris really bailed me out with UberGallery and I'm very grateful to him for this script.

Check out Chris Kankiewicz's other projects here and maybe he can inspire you to create something awesome.