PHP Photo Gallery

README - This PHP script uses jQuery and Fancybox - It is offered free and 'AS IS' by Raffia.ch.



<?php

    
// Simple PHP Gallery, Raffia.ch
    
    
function image_files()
    {
        
$galfiles array_filter((array) glob("images/*"), 'is_image');
        
natcasesort($galfiles);
        return 
array_values($galfiles);
    }
    
    function 
is_image($file)
    {
        return (bool) 
preg_match("/^(.*)\.(jpe?g|png|gif)$/i"$file);
    }
    
    
// gallery items
    
$gallery "";
    
    foreach (
image_files() as $file) {
        
$gallery .= "<a rel=\"fancybox\" target=\"_blank\" href=\"{$file}\"><img src=\"{$file}\" title=\"{$file}\"></a> ";
    }
    
    
// this script's code
    
$code highlight_string(file_get_contents(__FILE__), true);
    
    
// HTML template
    
include "template.html";
    
    
// end

The gallery script is short and simple!