# Bloxsom Plugin: ImageGalleryJQ # Author: Mike Downey # Version: 1.0 # Based on ImageGallery 0.5 # by Fletcher T. Penney # Changes from ImageGallery # 0.8 25/03/06 Shows thumbnails in normal view rather than the 'you must view # story' message. Thumbnails appear above the single image. # 0.9 08/09/14 Uses JQuery to load gallery images without having to reload the page # 1.0 10/08/14 Code tidied up, removed old unused gallery code. package imagegallery; # --- Configurable variables ---- # URL for images directory - will be added to beginning of images for the web browser to find them $images_url = "/gallery"; # Filepath for images directory on the server # This gets added to the gallery to find the files $images_path = "/htdocs/gallery/"; # Default thumbnail sub-directory name $thumbdir="thumbnails"; # Default image sub-directory name $imagesdir="images"; # Default comments sub-directory name $commentsdir="comments"; # Default number of columns $columns = 5; # HTML Code for gallery pieces $galleryhead = "
"; $galleryrowstart = "Click on the thumbnail to view the image
"; $gallery_url = "$images_url/$gallerypath"; $gallerypath = "$images_path/$gallerypath"; # Start with the JQuery code to display the images. $gallery=qq! !; # Now, find out how many images there are, and where my(@images); find(sub { $File::Find::name =~ /($imagetypes)$/i and push (@images, $File::Find::name) ;}, $gallerypath . $imagesdir); # Sort them. @images = sort @images; # Now fill out gallery if (scalar(@images) > 0) { $gallery .= $galleryhead . $galleryrowstart; # append to gallery so thumbnails follow main image my $count = 0; foreach $image (@images) { $count++; if ($count gt $columns) { $count = 1; $gallery.= $galleryrowend . $galleryrowstart; } $image =~ s/$images_path/$images_url/; $thumb = $image; $thumb =~ s/(.*)$imagesdir/$1$thumbdir/; $imagefile = $image; $imagefile =~ s/.*?([^\/]*)$/$1/; $imagefile =~ s/ /%20/g; # escape spaces in image name $thumb =~ s/ /%20/g; $imgtag = $galleryname.substr($imagefile, 0, rindex($imagefile, q{.} )); $gallery.= qq!$gallerycolstart $gallerycolend!; } $gallery.= $galleryrowend . $galleryfoot; } else { $gallery = "No images to display...