FlatGallery
Home
Why FlatGallery?
How To
Demo
Download
Project

PHP Powered

Valid XHTML 1.0!

Valid CSS!

Get Firefox!

Made on a Mac

SourceForge.net Logo

Quick Install

FlatGallery can be installed right out of the box with no need to configure anything (this is boring though).

  1. Download the lateset version of FlatGallery
  2. Untar the archive into your web directory:
    tar -zxvf flatgallery_X.X.tar.gz
  3. Chmod the images directory to 0755:
    chmod -R 0755 images/
  4. Chmod the thumbs/ directory to 0777:
    chmod -R 0777 thumbs/
  5. Put any number of Jpeg, Gif, or Png images in the images folder and then navigate to your your directory:
    http://my.webhost.com/flatgallery_X.X/

Configuring FlatGallery

FlatGallery has a number of configurations included with the default install. To use them, open index.php in your favorite text editor and edit the following values.

  • $title: Set this to the name of your gallery.
  • $stylesheet: Set this to the filename of your style sheet.
  • $img_dir: Set this to the directory which will hold your images (must be chmod 0777).
  • $thumb_dir: Set this to the directory which will hold your thumbnail cache (must be chmod 0777).
  • $folder_icon: Set this to a PNG image that will be the icon for folders (sub-galleries). You may need to run rebuild_thumbs() to make a nicely sized icon named "folder.png".
  • $cols: Set this to how many columns you want your gallery to have.
  • $rows: Set this to how many rows you want your gallery to have.
  • $show_name: Set this to display the filename under the thumbnail. (1 on, 0 off)
  • $show_size: Set this to display the file size under the thumbnail. (1 on, 0 off)

Changing the look and feel of FlatGallery is as simple as editing or replacing the stylesheet.

Integrating FlatGallery into an Existing Site

While FlatGallery will run just fine out of the box, you may want to integrate FlatGallery into a page that you already made. This site here is an example of that idea. The set up is for more advanced PHP users, but its still fairly straight forward.

  • Make sure that you link to the style sheet in the header as XHTML compliant.
  • Have the following line at the top of your PHP code
    require("flatgallery.class.php");
  • You will need to use $gal->set_link_requisit(string); when integrating. Set string to whatever needs to be in the GET variables with $offset. (example: the demo on this page uses "page=demo" for a link requisit for next and prev page links)
  • Read and use the class function definitions below.

FlatGallery Class Functions

Note: Only user functions are documented at this time. Internal function documentation will be forthcoming.

$gal = new flatgallery(void);
Class constructor

$gal->set_title(string);
Sets the title variable.

$gal->set_style(string);
Sets the stylesheet url.

$gal->set_dir(string);
Sets the images directory.

$gal->set_thumb_dir(string);
Sets the thumbnail cache directory.

$gal->set_thumb_size(int);
Sets the max length/width of the thumbnails in pixels.

$gal->set_folder_icon(string);
Sets the PNG image FlatGallery will refer to when building the resized icon "folder.png".

$gal->set_cols(int);
Sets the number of columns displayed per page.

$gal->set_rows(int);
Sets the number of rows displayed per page.

$gal->set_offset(int);
Sets the image number offset. (to work properly this MUST be set to $_GET['offset'] )

$gal->set_gallery(string);
Sets the gallery being viewed. Blank value will default to the parent gallery. (to work properly this MUST be set to $_GET['gallery'] )

$gal->set_show_filename(int);
Sets the display of the filename below the thumbnail to on or off (1 or 0).

$gal->set_show_filensize(int);
Sets the display of the filesize below the thumbnail to on or off (1 or 0).

$get->set_link_requisit(string);
Sets the link requisits for the Next and Prev page links. This is to be used when FlatGallery is integrated into an existing page that may use GET variables to control content. (example: the demo on this page uses "page=demo" as a requisit.)

$gal->do_parse(void);
Calls FlatGallery to search through the image directory and make sure all images have coresponding thumbnails in the thumbs directory. If they dont, it creates them. It then parses the thumbs directory and removes thumbnails which dont have a coresponding image in the images directory (ie. it was deleted or renamed).

$gal->head(void);
Prints out an XHTML valid header.

$gal->link_stylesheet(void);
Prints out the <link> line for the stylesheet. (This functions use outside of the <head> block is not XHTML complient).

$gal->display(void);
Displays the gallery page.

$gal->foot(void);
Prints out an XHTML valid footer.

$gal->rebuild_thumbs(void);
Will destroy all thumbnails and rebuild them based on the current file list of the image directory. This function should never be allowed to run each time the page is loaded (that would defeat the purpose of FlatGallery).

FlatGallery © 2005 FalseBlue.com and Ben Craton