iPAP: Photo Album Publisher
iPAP is a photo album publishing solution written in PHP by Markku Seguerra for the photos section on his site. Primarily developed for personal use, it is currently being prepared for general public use. Functionality is very basic right now, but the application works perfectly fine for its main purpose: display photo albums.
Credits to all people who’ve tried and tested this application, notably MaThIbUs, MtDewVirus, and my first ever public user, my girlfriend Monch. To the rest, sorry I couldn’t remember your URLs right now.
Important note: Since this a preview release only, a lot of things may change if I ever decide to move on with the development. No guarantees are made regarding support or compatibility, though I will try to do what I can concerning these matters.
Current Limitations
The current iteration of this software may provide what others may consider as “limitations.” Listed below are some of them:
- Only JPG files are currently supported.
- Uploading several photos at one time may be difficult, batch uploading not (yet?) available/implemented.
- A flat-file database storage class is used instead of MySQL for simplicity and portability.
- Uploading photos does not automatically resize them. Do that on the desktop with your nice photo-editing software. The default template is optimized for photos 500 pixels wide.
- The database backup file backup.zip is not password-protected and can be accessed directly! Secure the file. Consider this a privacy risk. You’ve been warned.
Requirements
- PHP 4 (tested on 4.2 and above)
- Version 2 of the GD Image Library
- Optional: mod_rewrite for clean permalinks
Installation
- Unzip everything to a folder on your desktop.
-
Edit ipap-config.php and change the
necessary variables, especially
$admin_username
,$admin_password
,$site_url
, and$gallery_url
. - Copy everything to your webserver, typically to a sub-directory photos/ of your domain. Like ( http://rebelpixel.com/photos/ )
-
CHMOD
to0777
the directory db/ and the files inside: db-uploads.php, db-albums.php, and db-photos.php, -
Create directories ipap-uploads and
ipap-temp, and
CHMOD
to0777
. -
CHMOD
backup.zip to0777
. -
At this point the directory structure should be like this:
/photos/ /photos/ipap-admin/ /photos/ipap-db/ /photos/ipap-lib/ /photos/ipap-temp/ /photos/ipap-uploads/
- You’re all set to go!
mod_rewrite
If you want to use mod_rewrite
to produce nice URIs and
permalinks, you need to set the variable $use_mod_rewrite
to
true
or 1
in
ipap-config.php. Create a
.htaccess file with the following rewrite rules:
RewriteEngine on RewriteBase / RewriteRule ^(.*)/(.*)?/?$ index.php?a=$1&i=$2 [QSA] RewriteRule ^(.*)?/?$ index.php?a=$1 [QSA]
However, if you have other rewrite rules in your root's .htaccess file, you might need to add modified rules to that file instead:
RewriteEngine on RewriteBase / RewriteRule ^photos_url/(.*)/(.*)/$ photos_path/index.php?a=$1&i=$2 [QSA] RewriteRule ^photos_url/(.*)/$ photos_path/index.php?a=$1 [QSA]
Where photos_url
is the “nice path” you intend
to use, and photos_path
is the real path to to your
iPAP install.
Template Tags
The following are tags you can use in your templates. Since version 0.7,
iPAP has adopted a PHP-based templating engine, instead of complicating
things with other complex template engines that use another syntax to learn.
Basically, if you know how to use PHP’s echo()
function,
you’re all set.
Important note: Some changes will probably be added later to simplify usage of these tags, but I will try to keep old tags and templates working properly, except for the 0.61 preview that used an entirely different template engine.
Global Tags
These tags can be used anywhere in ipap-gallery.tpl.php and ipap-album.tpl.php.
<?php echo $site_name; ?>
- The name of your main site.
<?php echo $site_url; ?>
- The URI of your main site.
<?php echo $gallery_name; ?>
- The name of your gallery/photos section, name of your iPAP install.
<?php echo $gallery_url; ?>
- The URI of your gallery/photos section, name of your iPAP install.
<?php echo $thumbnail_size; ?>
- Width/height of thumbnails, as set in ipap-config.php.
<?php echo $ipap_info; ?>
- Defaults to “iPAP: Photo Album Publisher”.
<?php echo $ipap_version; ?>
- Displays iPAP version, like “iPAP 0.7”.
<?php echo $timestamp; ?>
- Displays current GMT timestamp. Useful for tagging cache files.
Album Listing Tags
These tags can be used anywhere in
ipap-gallery.tpl.php and
ipap-album.tpl.php. As long as it is within
the
<?php if ($albums) { foreach ($albums as $album) { // begin albums loop ?>
...
<?php } } // end albums loop ?>
<?php echo $album['id']; ?>
- The ID of the album.
<?php echo $album['title']; ?>
- The title of the album. Processed with
wptexturize()
. <?php echo $album['title_raw']; ?>
- The title of the album as typed, without any text processing.
<?php echo $album['title_nohtml']; ?>
- The title of the album. Processed with
wptexturize()
but with HTML stripped. <?php echo $album['description']; ?>
- The description of the album. Processed with
wptexturize()
andautop()
. <?php echo $album['description_raw']; ?>
- The description of the album as typed, without any text processing.
<?php echo $album['description_nohtml']; ?>
- The description of the album. Processed with
wptexturize()
andautop()
but with HTML stripped. <?php echo $album['description_excerpt_nohtml']; ?>
- The description of the album. Processed with
wptexturize()
andautop()
but with HTML stripped, and trimmed to approximately 80 characters. <?php echo $album['sanitized_name']; ?>
- The
sanitize_title()
of the album. Processed withsanitize_title()
. <?php echo $album['date_created']; ?>
- Date when album was created. Formatted by PHP’s
date()
, according to$gallery_date_format
in ipap-config.php. <?php echo $album['date_edited']; ?>
- Date when album was last edited. Formatted by PHP’s
date()
, according to$gallery_date_format
in ipap-config.php. <?php echo $album['cover_image']; ?>
- Path to album’s cover image, as used in the
src
attribute in<img />
tags. <?php echo $album['cover_image_thumbnail']; ?>
- Path to the thumbnail of the album’s cover image, as used in the
src
attribute in<img />
tags. <?php echo $album['link']; ?>
- Link to the album.
<?php echo $album['photo_count']; ?>
- Number of photos in the given album.
Album Details Tags
These tags can be used anywhere in ipap-album.tpl.php.
<?php echo current_album['id']; ?>
- The ID of the current album.
<?php echo current_album['title']; ?>
- The title of the current album. Processed with
wptexturize()
. <?php echo current_album['title_raw']; ?>
- The title of the current album as typed, without any text processing.
<?php echo current_album['title_nohtml']; ?>
- The title of the current album. Processed with
wptexturize()
but with HTML stripped. <?php echo current_album['description']; ?>
- The description of the current album. Processed with
wptexturize()
andautop()
. <?php echo current_album['description_raw']; ?>
- The description of the current album as typed, without any text processing.
<?php echo current_album['description_nohtml']; ?>
- The description of the current album. Processed with
wptexturize()
andautop()
but with HTML stripped. <?php echo current_album['description_excerpt_nohtml']; ?>
- The description of the current album. Processed with
wptexturize()
andautop()
but with HTML stripped, and trimmed to approximately 80 characters. <?php echo current_album['sanitized_name']; ?>
- The
sanitize_title()
of the current album. Processed withsanitize_title()
. <?php echo current_album['date_created']; ?>
- Date when current album was created. Formatted by PHP’s
date()
, according to$gallery_date_format
in ipap-config.php. <?php echo current_album['date_edited']; ?>
- Date when current album was last edited. Formatted by PHP’s
date()
, according to$gallery_date_format
in ipap-config.php. <?php echo current_album['cover_image']; ?>
- Path to current album’s cover image, as used in the
src
attribute in<img />
tags. <?php echo current_album['cover_image_thumbnail']; ?>
- Path to the thumbnail of the current album’s cover image, as used in the
src
attribute in<img />
tags. <?php echo current_album['link']; ?>
- Link to the current album.
<?php echo current_album['permalink']; ?>
- Link to the current album.
<?php echo current_album['photo_count']; ?>
- Number of photos in the given current album.
Thumbnail Listing Tags
These tags can be used anywhere in
ipap-album.tpl.php.
As long as it is within
the
<?php if ($thumbnails) { foreach ($thumbnails as $thumbnail) { // begin thumbnails loop ?>
...
<?php } } // end thumbnails loop ?>
<?php echo thumbnail['id']; ?>
- The ID of the current thumbnailed photo.
<?php echo thumbnail['title']; ?>
- The title of the thumbnailed photo. Processed with
wptexturize()
. <?php echo thumbnail['title_raw']; ?>
- The title of the thumbnailed photo as typed, without any text processing.
<?php echo thumbnail['title_nohtml']; ?>
- The title of the thumbnailed photo. Processed with
wptexturize()
but with HTML stripped. <?php echo thumbnail['caption']; ?>
- The caption of the thumbnailed photo. Processed with
wptexturize()
andautop()
. <?php echo thumbnail['caption_raw']; ?>
- The caption of the thumbnailed photo as typed, without any text processing.
<?php echo thumbnail['caption_nohtml']; ?>
- The caption of the thumbnailed photo. Processed with
wptexturize()
andautop()
but with HTML stripped. <?php echo thumbnail['caption_excerpt_nohtml']; ?>
- The caption of the thumbnailed photo. Processed with
wptexturize()
andautop()
but with HTML stripped, and trimmed to approximately 80 characters. <?php echo thumbnail['date_created']; ?>
- Date when thumbnailed photo was created. Formatted by PHP’s
date()
, according to$gallery_date_format
in ipap-config.php. <?php echo thumbnail['date_edited']; ?>
- Date when thumbnailed photo was last edited. Formatted by PHP’s
date()
, according to$gallery_date_format
in ipap-config.php. <?php echo thumbnail['date_taken']; ?>
- Date when thumbnailed photo was taken, extracted from EXIF data if available. Formatted by PHP’s
date()
, according to$gallery_date_format
in ipap-config.php. <?php echo thumbnail['location']; ?>
- Location where photo was taken, if available.
<?php echo thumbnail['image']; ?>
- Path to the thumbnail of the current thumbnailed photo, as used in the
src
attribute in<img />
tags. <?php echo thumbnail['link']; ?>
- Link to the current thumbnailed photo.
Current Photo Tags
These tags can be used anywhere in ipap-album.tpl.php.
<?php echo current_photo['id']; ?>
- The ID of the current photo.
<?php echo current_photo['title']; ?>
- The title of the thumbnailed photo. Processed with
wptexturize()
. <?php echo current_photo['title_raw']; ?>
- The title of the thumbnailed photo as typed, without any text processing.
<?php echo current_photo['title_nohtml']; ?>
- The title of the thumbnailed photo. Processed with
wptexturize()
but with HTML stripped. <?php echo current_photo['caption']; ?>
- The caption of the thumbnailed photo. Processed with
wptexturize()
andautop()
. <?php echo current_photo['caption_raw']; ?>
- The caption of the thumbnailed photo as typed, without any text processing.
<?php echo current_photo['caption_nohtml']; ?>
- The caption of the thumbnailed photo. Processed with
wptexturize()
andautop()
but with HTML stripped. <?php echo current_photo['caption_excerpt_nohtml']; ?>
- The caption of the thumbnailed photo. Processed with
wptexturize()
andautop()
but with HTML stripped, and trimmed to approximately 80 characters. <?php echo current_photo['date_created']; ?>
- Date when thumbnailed photo was created. Formatted by PHP’s
date()
, according to$gallery_date_format
in ipap-config.php. <?php echo current_photo['date_edited']; ?>
- Date when thumbnailed photo was last edited. Formatted by PHP’s
date()
, according to$gallery_date_format
in ipap-config.php. <?php echo current_photo['date_taken']; ?>
- Date when thumbnailed photo was taken, extracted from EXIF data if available. Formatted by PHP’s
date()
, according to$gallery_date_format
in ipap-config.php. <?php echo current_photo['location']; ?>
- Location where photo was taken, if available.
<?php echo current_photo['width']; ?>
- The width of the current photo.
<?php echo current_photo['height']; ?>
- The height of the current photo.
<?php echo current_photo['image']; ?>
- Path to the thumbnail of the current thumbnailed photo, as used in the
src
attribute in<img />
tags. <?php echo current_photo['link']; ?>
- Link to the current thumbnailed photo.
<?php echo current_photo['permalink']; ?>
- Link to the current thumbnailed photo.
<?php echo current_photo['filesize_kb']; ?>
- The filesize of the current photo.
<?php echo current_photo['next_link']; ?>
- The link to the next photo, if available.
<?php echo current_photo['next_image_thumbnail']; ?>
- Path to the thumbnail of the next photo, as used in the
src
attribute in<img />
tags. <?php echo current_photo['next_title_raw']; ?>
- The title of the next photo as typed, without any text processing.
<?php echo current_photo['next_title_nohtml']; ?>
- The title of the next photo. Processed with
wptexturize()
but with HTML stripped. <?php echo current_photo['next_title']; ?>
- The title of the next photo. Processed with
wptexturize()
. <?php echo current_photo['next_caption_excerpt_nohtml']; ?>
- The caption of the next photo. Processed with
wptexturize()
andautop()
but with HTML stripped, and trimmed to approximately 80 characters. <?php echo current_photo['next_caption_raw']; ?>
- The caption of the next photo as typed, without any text processing.
<?php echo current_photo['next_caption_nohtml']; ?>
- The caption of the next photo. Processed with
wptexturize()
andautop()
but with HTML stripped. <?php echo current_photo['next_caption']; ?>
- The caption of the next photo. Processed with
wptexturize()
andautop()
but with HTML stripped. <?php echo current_photo['prev_link']; ?>
- The link to the previous photo, if available.
<?php echo current_photo['prev_image_thumbnail']; ?>
- Path to the thumbnail of the previous photo, as used in the
src
attribute in<img />
tags. <?php echo current_photo['prev_title_raw']; ?>
- The title of the previous photo as typed, without any text processing.
<?php echo current_photo['prev_title_nohtml']; ?>
- The title of the previous photo. Processed with
wptexturize()
but with HTML stripped. <?php echo current_photo['prev_title']; ?>
- The title of the previous photo. Processed with
wptexturize()
. <?php echo current_photo['prev_caption_excerpt_nohtml']; ?>
- The caption of the previous photo. Processed with
wptexturize()
andautop()
but with HTML stripped, and trimmed to approximately 80 characters. <?php echo current_photo['prev_caption_raw']; ?>
- The caption of the previous photo as typed, without any text processing.
<?php echo current_photo['prev_caption_nohtml']; ?>
- The caption of the previous photo. Processed with
wptexturize()
andautop()
but with HTML stripped. <?php echo current_photo['prev_caption']; ?>
- The caption of the previous photo. Processed with
wptexturize()
andautop()
but with HTML stripped.
Filters
- wptexturize()
- Converts quotes and double quotes for snappy punctuations. Taken from WordPress.
- autop()
- Converts linebreaks and paragraphs. Taken from WordPress.
- sanitize_title()
- Cleans text for use in permalinks. Taken from WordPress.
More details and additions on template filters next time.
Copying
Copying, modification and redistribution is allowed under the terms of the GPL, better explained by the CC–GPL (Creative Commons Deed). A link to my site and the projects’s page will be greatly appreciated.