Skip to content

An all-in-one php photo gallery script, designed to just be dropped into a folder of photos. It outputs a simple, but beautiful photo gallery that's optimized for use on mobile devices.

Notifications You must be signed in to change notification settings

dev/photo-gallery

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

Photo Gallery

A simple all-in-one php photo gallery script intended to be simply dropped into a directory of photos. It displays all the photos (jpg/jpeg only) in a simple visual interface, generating thumbnails on the fly to make the gallery load fast. It now also includes jQuery and the Magnific Lightbox (styles and js both from CDNs), so that the links to images will open in a lightbox instead of directly linking to them - this helps with usability.

150 lines of clean, well-commented php/html/css/js. Enjoy!

Preview

Live demo: http://gallery.jpederson.com


Quick Install (cli)

To quickly install the script from the command line, navigate to the directory you'd like to install this script to (inside a folder of photos), and execute the following command.

curl -O https://raw.githubusercontent.com/jpederson/photo-gallery/master/index.php

And then, while you're in the command line, run the index.php file to pre-generate all the thumbnails for this gallery. See notes below in the 'Generating Thumbnails' section to see why it's better to pre-generate your thumbnails via the command line.

php index.php

Generating Thumbnails

There are two methods of generating thumbnails:

  1. Run the script in the command line. (preferred) This method usually bypasses any script execution time limits in your PHP installation. The script is developed to detect when you're in the command line (CLI), and not output HTML, instead creating a log as it goes through and generates thumbnails of each image. This method is quicker, and will pre-generate all your thumbnails at once, so that when you view the gallery in a browser, it just works right away.
  2. Refresh the page several times in a browser to generate thumbnails for a large number of images. This method is slower, and may take several refreshes, because the script may exceed the maximum execution time. Not to worry though, it skips images for which it has already created thumbnails, so each refresh, it just starts from the next image that needs a thumbnail, and will eventually make it through all the images.

Notes

The only important thing to note is that any photos whose filenames begin with an underscore (_) are ignored by the script - when thumbnails are generated, they're saved to filenames beginning with an underscore, so you can manually override your thumbnails by saving versions of your photos with an underscore in front of their filename. Equally, if you'd like to regenerate the thumbnials, just delete the _ version of the photo, and the script will detect that the thumbnail was deleted (on the next pageload or script execution) and regenerate the thumbnail for that photo.


Developed with love by James Pederson.

About

An all-in-one php photo gallery script, designed to just be dropped into a folder of photos. It outputs a simple, but beautiful photo gallery that's optimized for use on mobile devices.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%