# Photo Gallery Feature - Complete Implementation ## Overview The Photo Gallery feature allows 4WDCSA members to create, manage, and view photo albums with a carousel interface for browsing and a lightbox viewer for detailed photo viewing. ## Database Schema ### photo_albums table ```sql - album_id (INT, PK, AUTO_INCREMENT) - user_id (INT, FK to users) - title (VARCHAR 255, NOT NULL) - description (TEXT, nullable) - cover_image (VARCHAR 500, nullable - stores file path) - created_at (TIMESTAMP) - updated_at (TIMESTAMP) - UNIQUE INDEX on user_id (one album per user for now, can be modified) - INDEX on created_at for sorting ``` ### photos table ```sql - photo_id (INT, PK, AUTO_INCREMENT) - album_id (INT, FK to photo_albums, CASCADE DELETE) - file_path (VARCHAR 500, NOT NULL) - caption (VARCHAR 500, nullable) - display_order (INT, default 0) - created_at (TIMESTAMP) - INDEX on album_id for quick lookups - INDEX on display_order for sorting ``` ## File Structure ### Pages (Public-Facing) - `src/pages/gallery/gallery.php` - Main carousel view of all albums - `src/pages/gallery/view_album.php` - Detailed album view with photo grid and lightbox - `src/pages/gallery/create_album.php` - Form to create new albums and upload initial photos ### Processors (Backend Logic) - `src/processors/save_album.php` - Creates new album and handles initial photo uploads - `src/processors/update_album.php` - Updates album metadata and handles additional photo uploads - `src/processors/delete_album.php` - Deletes entire album with all photos and files - `src/processors/delete_photo.php` - Deletes individual photos from album - `src/processors/get_album_photos.php` - API endpoint returning album photos as JSON ### Styling All styling is embedded in each PHP file using `