Add media gallery collection & block with lightbox#1124
Conversation
Network-free helpers to extract a video ID from common YouTube URL forms and build nocookie embed + thumbnail URLs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A tenant-scoped, reusable collection of media items (image/video uploads and YouTube videos) with optional per-item captions. Follows the Biographies pattern: tenantField, contentHash, documentReferences, and revalidate hooks. Registered under the Content admin group. Refs #576 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Renders a curated gallery as a responsive grid or masonry of image, video, and YouTube thumbnails that open into a click-through carousel lightbox (Radix Dialog + Embla). Only the active slide loads its YouTube iframe. Editor controls: heading, rich-text description, layout, and column count. Registered in RenderBlocks and the default block list. Refs #576 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Creates the galleries tables and gallery block tables. Migration safety warnings are the standard new-collection FK/ALTER patterns (same as the add_announcements migration); data is preserved via INSERT...SELECT. Refs #576 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Migration Safety CheckFound 13 potential issues: 20260619_143710_add_galleries.ts Warning (line 16): DELETE keyword detected - review for data loss FOREIGN KEY (\`gallery_id\`) REFERENCES \`galleries\`(\`id\`) ON UPDATE no action ON DELETE set null,Warning (line 17): DELETE keyword detected - review for data loss FOREIGN KEY (\`_parent_id\`) REFERENCES \`home_pages\`(\`id\`) ON UPDATE no action ON DELETE cascadeWarning (line 44): DELETE keyword detected - review for data loss FOREIGN KEY (\`gallery_id\`) REFERENCES \`galleries\`(\`id\`) ON UPDATE no action ON DELETE set null,Warning (line 45): DELETE keyword detected - review for data loss FOREIGN KEY (\`_parent_id\`) REFERENCES \`_home_pages_v\`(\`id\`) ON UPDATE no action ON DELETE cascadeWarning (line 71): DELETE keyword detected - review for data loss FOREIGN KEY (\`gallery_id\`) REFERENCES \`galleries\`(\`id\`) ON UPDATE no action ON DELETE set null,Warning (line 72): DELETE keyword detected - review for data loss FOREIGN KEY (\`_parent_id\`) REFERENCES \`pages\`(\`id\`) ON UPDATE no action ON DELETE cascadeWarning (line 99): DELETE keyword detected - review for data loss FOREIGN KEY (\`gallery_id\`) REFERENCES \`galleries\`(\`id\`) ON UPDATE no action ON DELETE set null,Warning (line 100): DELETE keyword detected - review for data loss FOREIGN KEY (\`_parent_id\`) REFERENCES \`_pages_v\`(\`id\`) ON UPDATE no action ON DELETE cascadeWarning (line 124): DELETE keyword detected - review for data loss FOREIGN KEY (\`media_id\`) REFERENCES \`media\`(\`id\`) ON UPDATE no action ON DELETE set null,Warning (line 125): DELETE keyword detected - review for data loss FOREIGN KEY (\`_parent_id\`) REFERENCES \`galleries\`(\`id\`) ON UPDATE no action ON DELETE cascadeWarning (line 142): DELETE keyword detected - review for data loss FOREIGN KEY (\`_parent_id\`) REFERENCES \`galleries\`(\`id\`) ON UPDATE no action ON DELETE cascadeWarning (line 158): DELETE keyword detected - review for data loss FOREIGN KEY (\`tenant_id\`) REFERENCES \`tenants\`(\`id\`) ON UPDATE no action ON DELETE set nullWarning (line 165): ALTER keyword detected - review for data loss sql`ALTER TABLE \`payload_locked_documents_rels\` ADD \`galleries_id\` integer REFERENCES galleries(id);`,Review these patterns and add backup/restore logic if needed. See |
|
Preview deployment: https://gallery-collection-576.preview.avy-fx.org |
Description
Adds a media Gallery feature: a reusable, tenant-scoped collection of photos, uploaded videos, and YouTube videos, plus a block that renders them as a responsive grid (or masonry) that opens into a full-screen, click-through carousel lightbox. Follows the existing Biographies/Team patterns.
Related Issues
Refs #576
Key Changes
Galleriescollection —tenantField, admin-onlytitle,items[]array (per-itemtypeselect ofupload/youtube, conditionalmedia/youtubeUrl/youtubeTitle, optionalcaption),contentHash,documentReferences, and revalidate hooks. Access viaaccessByTenantRole('galleries'), admin group Content.Galleryblock — required tenant-filteredgalleryrelationship; optionalheading+ rich-textdescription;layout(grid/masonry) andcolumns(2/3/4, default 4). Registered inRenderBlocksandDEFAULT_BLOCKS.youtube-nocookieautoplay iframe. Captions show in the lightbox only.getYouTubeIdutility — network-free parser for common YouTube URL forms, plus embed/thumbnail builders.How to test
pnpm migratethenpnpm dev.Screenshots / Demo video
TODO: add grid + lightbox screenshots.
Migration Explanation
20260619_143710_add_galleriescreates thegalleries,galleries_items,galleries_document_referencestables and the gallery block tables, and adds a nullablegalleries_idFK topayload_locked_documents_rels.migrate:checkwarnings are the standard new-collection FKON DELETE/ALTERpatterns (identical to the mergedadd_announcementsmigration); data is preserved viaINSERT...SELECT.Future enhancements / Questions
🤖 Generated with Claude Code