Photo album for CMSimple_XH
The includephp plugin allows CMSimple_XH users to safely include and execute PHP files directly in page content. It is designed for static includes only, executing PHP files placed in a controlled directory plugins/includephp/php/ and inserting their output into the CMS page.
Description
This embedable PHP photo album is a fully self-contained, responsive gallery with the following features:
- Automatic thumbnails: Scans all images in
/userfiles/images/, supports PNG, GIF, JPEG, WEBP, and preserves transparent backgrounds. Thumbnails are generated in/userfiles/thumbnails/. - Clean filenames: Displayed below thumbnails, extensions removed, underscores and dashes replaced by spaces, original capitalization preserved.
- Lightbox: Click a thumbnail to enlarge, with the title below the image. Navigate using arrow keys (← →) and close with
Escor the × button. - Fade-in/fade-out animation: Smooth opening and closing of the lightbox.
- Responsive layout: Auto-adjusts to screen size. Grid layout for thumbnails. Container auto-height prevents scrollbars or extra whitespace.
- Mobile swipe support: Swipe left/right on touch devices to navigate images.
- Single-file embedable: All CSS, JS, and PHP in one file (
photoalbum.php). Namespaced container#photo-album-containerprevents conflicts with CMSimple_XH templates.
Setup
- Upload your images to
/userfiles/images/ - Make sure
/userfiles/thumbnails/is writable (chmod 0777 if necessary) - Upload
photoalbum.phpto a PHP-enabled folder, e.g.,/safephp/
Usage in CMSimple_XH
Inline include (recommended)
Place this where you want the photo album to appear:
{{{includephp('photoalbum.php')}}}
This executes the PHP file and embeds the gallery directly in your page. All CSS and JS are included, so the lightbox, swipe, and responsive layout work automatically.
Optional: iframe include
<iframe src="/plugins/includephp/php/photoalbum.php"
style="width:100%;height:600px;border:none;"></iframe>
Use this if you want the album isolated from other page styles. Note: the iframe height is fixed unless you add dynamic resizing JavaScript.
Extra Tips
- Adding new images: Upload to
/userfiles/images/and reload the page; thumbnails will be generated automatically. - Regenerating thumbnails: Delete all files in
/userfiles/thumbnails/and reload the page. - Adjusting thumbnail size: Edit
createThumbnail($srcPath,$thumbPath,$maxWidth=400,$maxHeight=300)inphotoalbum.php.
Summary
With a single include, you have a fully functional, responsive, swipeable, transparent photo album embedded in CMSimple_XH.
