Integrate Minishowcase Gallery Into WordPress

Under: Wordpress 12 comments

After using WordPress for a year, I have tried many hacks and tips, and discovered many fun features myself. Here I’m going to show you how to integrate an Ajax gallery called minishowcase into WordPress.

minishowcase is a small and simple php/javascript online photo gallery, powered by AJAX that allows you to easily show your images online, without complex databases or coding, allowing to have an up-and-running gallery in a few minutes.

The official  version of minishowcase does not detect photos in sub folder. You need to download another version called minishowcase-scubabeer.zip if you want to modify your own, alternatively you can download the modified version I m using.

This is the link you can download the minishowcase that detects sub folders, you can also check up the result here or download the version I modified.

Sample gallery


    Issues:

  1. A website that already have thousands of photos before installing WordPress. You need to display those files along with the photos in wordpress
  2. You would like to display all your photos in the Media Gallery on a separate professional photographer looking page

Solution: modified version of minishowcase Ajax gallery

    Features:

  1. A script detects all photos in uploads folder of WordPress automatically.
  2. Exclude thumbnails and small photos generated in wordpress in the gallery
  3. Display your photos professionally
  4. Can be modified to have a similar layout as your main site.

For those would like to get your hands dirty, these is how to modify minishowcase-scubabeer.zip. For those would like to use my version directly, you can drump to “what’s next” section at the bottom of the page to learn how to install it.

One disadvantage of minishowcase is the gallery folder is fixed (called galleries) which locates inside minishowcase root folder. I need to change this limitation to have it detect the uploads folder in my wordpress.

Change photo directory

I opened Ajax.gateway.php under library folder and change the folder directory from $base_path/galleries/$id/ to $base_path/../wp-content/uploads/$id/ . There are five places to change in this file. Then do the same thing for ajax.functions.js and you need to change four places for this one. The third file you need to change is index.php at root folder. There are two lines need to be changed. Its quite simple so far only search and replace.

Exclude the thumb nail and small photo generated by WordPress

Locate this code from ajax.gateway.php

	// open directory and parse file list
		$num = 0;
		if ($dh = opendir($dir)) {
			// iterate over file list & output all filenames
			while (($filename = readdir($dh)) !== false) {
				$pinfo = pathinfo($filename);
				if ((strpos($filename,"_") !== 0)
				&& (strpos($filename,".") !== 0)
				&& (!in_array($filename, $hidden_files))
				&& (in_array(strToLower($pinfo["extension"]),$settings['allowed_extensions']))
				) {
					$all_thumbs[] = $filename;
				}
			}
			// close directory
			closedir($dh);
		}

and replace it with this longer version which is saying if the file’s name contains 150×150 or 300xsth or sthx300, it will not be displayed.

	// open directory and parse file list
		$num = 0;
		if ($dh = opendir($dir)) {
			// iterate over file list & output all filenames
			while (($filename = readdir($dh)) !== false) {
				$pinfo = pathinfo($filename);
				if ((strpos($filename,"_") !== 0)
				&& (strpos($filename,".") !== 0)
				&& (strpos($filename,"150x150") == 0)
				&& (strpos($filename,"300x") == 0)
				&& (strpos($filename,"x300") == 0)
				&& (!in_array($filename, $hidden_files))
				&& (in_array(strToLower($pinfo["extension"]),$settings['allowed_extensions']))
				) {
					$all_thumbs[] = $filename;
				}
			}
			// close directory
			closedir($dh);
		}

All done!!

What’s next

Configure your gallery settings according to Instructions.htm. You can also stylize it to have a similar look of your main site(for this part please read the instruction of minishowcase) Upload the modified minishowcase into the same level as your wp-content.
Copy _info.txt and index.php in galleries folder to uploads folder.

Your gallery URL will be http://yourdomain/minishocase
if you change minihsowcase root folder name. The URL of your gallery will be http://yourdomain/yourfoldername . have fun!!