demo
templates
install
contact
Home Install Home Add-ons Gallery 1.3.1

Integration with Gallery

Contentor can be modified to add a photo bar of random photos in the template. The photos for the photo bar can be drawn from a Photo Gallery in the folder "photos". Rename the desired album to "photos" (click the "rename album" link in admin mode - note that this is different than "edit title"). You can switch photo albums used by renaming albums and then re-running the integration routine.

Modifications to Gallery

NOTE: these modifications are for Gallery Version 1.3.1 - (latest version here)

Gallery can be modified to create all thumbnails with the same height (for horizonal photo bar) or the same width (for vertical photo bar). Once the modification below is made, the thumbnail image size in the gallery properties would be appended with an 'h' or a 'w' to specify the desired height or width respectively. For example, to create a vertical photo bar of 120-pixel-wide images, set the thumbnail size to '120w'.  Edit the file "util.php" to replace the function "resize_image" with the following code:


function resize_image($src, $dest, $target) {
	global $gallery;
	if (!strcmp($src,$dest)) {
		$useTemp = true;
		$out = "$dest.tmp";
	} else {
		$out = $dest;
	}
	if (preg_match("~w$~i", $target)) {
		$target = 0 + $target;	// force to integer
		$err = exec_wrapper(toPnmCmd($src) . " | "
                      . NetPBM("pnmscale", " -width $target") . " | "
                      . fromPnmCmd($out));
	} elseif (preg_match("~h$~i", $target)) {
		$target = 0 + $target;	// force to integer
		$err = exec_wrapper(toPnmCmd($src) . " | "
                      . NetPBM("pnmscale", " -height $target") . " | "
                      . fromPnmCmd($out));
	} else {
		$err = exec_wrapper(toPnmCmd($src) . " | "
                      . NetPBM("pnmscale", " -xysize $target $target") . " | "
                      . fromPnmCmd($out));
	}

	if (fs_file_exists("$out") && fs_filesize("$out") > 0) {
		if ($useTemp) {
			fs_copy($out, $dest);
			fs_unlink($out);
		}
		return 1;
	} else {
		return 0;
	}
}

Automatic resizing upon upload

Gallery normally keeps the original upload file, no matter how large it may be. By adding the following code to the file "classes/Album.php", you can prevent the storage of a file larger than the "Auto-Resize" setting (in Album Properties).

Add the code after line # 527 (which reads: "$item = new AlbumItem();")

			/* added to resize first */
			$max_size = $gallery->album->fields["resize_size"];
			list($w, $h) = getimagesize("$dir/$name.$tag");
			if ($w > $max_size || $h > $max_size ) {
				resize_image("$dir/$name.$tag", "$dir/$name.$tag", $max_size);
			}