How to Use the BacklitPhoto Class
You create an instance of the BacklitPhoto class like this:
1 | $photo = new BacklitPhoto($photo_id); |
The photo_id parameter corresponds to the photo_id field in the bl_photos table in your database.
To get the photo's caption you use the getCaption method:
1 | echo $photo->getCaption(); |
To get the photo's credit you use the getCredit method:
1 | echo $photo->getCredit(); |
To get the photo's publish date, use the getPublishDate method:
1 | $date = $photo->getPublishDate(); |
To format the publish date use PHP's date function:
1 | echo date('M j, Y', strtotime($photo->getPublishDate())); |
To get the album_id of the album that the photo is associated with, you use the getAlbumID method:
1 | $album_id = $photo->getAlbumID(); |
To get the title of the album that the photo is assoicated with, you use the getAlbumTitle method:
1 | echo $photo->getAlbumTitle(); |
To generate the HTML breadcrumbs for a photo, use the getBreadcrumbTrail method:
1 | echo '<div id="breadcrumbs">' . $photo->getBreadcrumbTrail() . '</div>'; |
To generate a HTML table of the photo with the photo's details and links to the previous and next photos, use the getPhotoAsTable method:
1 | echo '<div class="photo_album align_center">' . $photo->getPhotoAsTable() . '</div>'; |
If the getPhotoAsTable method does not suit your needs, you can build your own display by using the methods above and the getPreviousPhoto and getNextPhoto methods. The getPreviousPhoto and getNextPhoto methods each return an integer that is the photo_id for the previous and next photo respectively.
The downloadOriginal method initiates a download of the original high-res photo:
1 | if ($_GET['action'] == 'download') $photo->downloadOriginal(); |