CK-Gallery Description
CK-Gallery is a simple, yet powerful, PHP photo gallery that will basically manage itself for you. CK-Gallery supports .jpg, .gif & .png image types, and will automatically creates thumbnails on the fly. The main feature of this gallery is it automatically outputs XHTML compliant markup for inclusion on a web page. The CK-Gallery will also automatically prune it's thumbnails, so when you delete an image from the images folder, it will delete the corresponding thumbnail. The gallery also creates a log file for reference and debugging. The CK-Gallery is licensed under the GNU General Public License version 3.0.
With the update to version 1.0.0 CK-Gallery now has dynamic pagination. This will let users with larger galleries split the gallery up into several smaller pages and allow visitors to easily navigate to those pages via a small navigation bar below the gallery. Among other changes, GZip compression was implemented on the default index.php file included with the gallery, reducing bandwidth and improving script execution speed significantly when active.
Requirements
Due to technical limitations of the functions used, you must be running PHP version 4.0.6 or higher in a Linux environment, or version 4.3.0 on a Windows environment. Also, you must have the PHP GD version 2.0.1 or later installed (2.0.28 or later is recommended).
The oldest PHP version this script has been successfully tested on was a Linux system running PHP version 4.3.11 and PHP GD version 2.0.28, if you've tested CK-Gallery successfully on an older version of Linux or on any Windows server, I'd like to know, please contact me.
For more information on PHP and PHP GD, please see http://www.php.net
Included Files/Folders
/docs - Gallery documentation /gallery - Default image directory /thickbox - Thickbox files ck-gallery.php - Main gallery script gallery.css - Gallery style sheet index.php - Contains the page markupSimple Installation
- Upload the entire contents of this directory to your web server in the directory where you would like the gallery to be displayed. (Example: http://www.domain-name.com/photo-gallery/)
- Upload your images to the /gallery directory.
- Open your web browser and navigate to the directory where you installed the gallery and the script should generate thumbnails and display your images.
Install to Pre-Existing Web Page
- If you wish to change the name or location of the images folder, thumbnails folder, or log file, or you would like to enable pagination, open ck-gallery.php and edit the variables found in the top of the script.
- Upload ck-gallery.php to your web server.
- Insert the following code to your page where you would like the gallery to be displayed:
<?php include_once('path-to-file/ck-gallery.php'); ?>- If using pagination, copy the "Pagination" portion of gallery.css into your own style sheet and edit it to your liking.
- Open up your web browser and navigate to your page, this will create the directory structure for you if it doesn't already exist.
- Upload your images to the images directory ("/gallery" by default).
- Refresh the page in your browser and the script should generate thumbnails and display your images.
Customizing your Gallery
The CK-Gallery comes with class and id elements already in place, this allows for customization of the look and feel of your gallery. All you have to do is edit the CSS style sheet, or create your own, and you'll be off in no time.
This is the typical structure of the XHTML output:
<div id="gallery-wrapper"> <div id="ck-gallery"> <a href="#"><img src="#" alt="#" /></a> <a href="#"><img src="#" alt="#" /></a> <a href="#"><img src="#" alt="#" /></a> </div> </div>Also, here's the pagination navigation structure:
<ul id="ck-pagination"> <li class="inactive"><</li> <li class="current-page">1</li> <li><a href="?page=2">2</a></li> <li><a href="?page=3">3</a></li> <li><a href="?page=4">4</a></li> <li><a href="?page=2">></a></li> </ul>Pagination
To enable pagination, open ck-gallery.php, find "$imgPerPage = 0;" at the top and set this value to the number of images you would like to display per page.
NOTE: If pagination is enabled, the script will generate thumbnails on a per-page basis. You do not have to worry about this though, the first time a visitor visits a page without thumbnails, it will automatically generate the thumbnails, however this may cause the page to take several seconds to load while this processes.
Page Caching
Page caching can drastically reduce the CPU load on your server and is more efficient for servers with high traffic. To enable page caching, edit the "$expireTime = 0;" value found at the top of the ck-gallery.php script. This value is the time in minutes after which a new cach file will be generated.
NOTE: At the moment, if you upload new images or make a change to the script while caching is enabled, you will have to delete the cache files or wait the ammouont of time specified before your changes will be reflected on the page.
To delete the cache files, use an FTP program or shell access to delete the "gallery-cache" folder and all of it's contents.
Update Notifications
To enable the update notification, open ck-gallery.php, find "$verCheck = 0;" and change this value to 1. Once done, whenever an update to CK-Gallery is available, a message will appear at the bottom of your gallery informing you of this new version and providing a link to the new version.
Also, don't forget to follow @ckgallery on twitter to be notified of updates and other news.
GZip Compression
In order to improve the performance and reduce the bandwidth of your gallery, it's recomended that you enable gzip compression on the page for which your gallery is being displayed. In order to accomplish this, place the following code at the very beginning of the page to which the gallery will be displayed:
<?php substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') ? ob_start("ob_gzhandler") : ob_start(); ?>This code must be the very fist thing the browser loads or it will cause errors. See the index.php file included with the gallery for an example of how this code is layed out.
NOTE: Compression is already enabled in the default index.php, if you are getting errors related to this, remove the first line of index.php and please send me an email noting your version of PHP and any other relevant info.
Contact
If you have any questions or comments, please email me: Gallery [at] Web-Geek [dot] net
Shout Outs
Thanks go out to Dual for inadvertently inspiring me to get up off my ass and program this.
Also, thanks to Penguin for answering questions throughout the entire development process and for some bug testing.
Thanks also to Nak for rigorous beta testing that helped me iron out a number of bugs and fix backwards capabilities.
Lastly, thanks to the StackOverflow.com community for help here and there.
Additional Info
For more info and to download CK-Gallery, please visit: http://code.web-geek.net/ck-gallery