Skip to content

Add media gallery collection & block with lightbox#1124

Open
rchlfryn wants to merge 4 commits into
mainfrom
gallery-collection-576
Open

Add media gallery collection & block with lightbox#1124
rchlfryn wants to merge 4 commits into
mainfrom
gallery-collection-576

Conversation

@rchlfryn

Copy link
Copy Markdown
Collaborator

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

  • Galleries collectiontenantField, admin-only title, items[] array (per-item type select of upload/youtube, conditional media/youtubeUrl/youtubeTitle, optional caption), contentHash, documentReferences, and revalidate hooks. Access via accessByTenantRole('galleries'), admin group Content.
  • Gallery block — required tenant-filtered gallery relationship; optional heading + rich-text description; layout (grid/masonry) and columns (2/3/4, default 4). Registered in RenderBlocks and DEFAULT_BLOCKS.
  • Lightbox — Radix Dialog + Embla carousel with next/prev (arrows + keyboard). Images, uploaded videos, and YouTube share one carousel; only the active slide loads its youtube-nocookie autoplay iframe. Captions show in the lightbox only.
  • getYouTubeId utility — network-free parser for common YouTube URL forms, plus embed/thumbnail builders.
  • Migration for the new tables + tests.

How to test

  1. pnpm migrate then pnpm dev.
  2. In admin (Content → Galleries), create a gallery with a mix of image/video uploads and YouTube URLs; add captions.
  3. Add a Gallery block to a page, select the gallery, try grid vs masonry and 2/3/4 columns, set an optional heading/description.
  4. On the frontend: confirm the grid renders, clicking a thumbnail opens the lightbox, arrows/keyboard cycle through items, YouTube plays in-modal and stops when you navigate away.

Screenshots / Demo video

TODO: add grid + lightbox screenshots.

Migration Explanation

20260619_143710_add_galleries creates the galleries, galleries_items, galleries_document_references tables and the gallery block tables, and adds a nullable galleries_id FK to payload_locked_documents_rels. migrate:check warnings are the standard new-collection FK ON DELETE/ALTER patterns (identical to the merged add_announcements migration); data is preserved via INSERT...SELECT.

Future enhancements / Questions

  • Seed data for galleries is not included yet (MVP-optional).
  • No click-through between separate galleries; no oEmbed/metadata fetching for YouTube; documents intentionally out of scope.

🤖 Generated with Claude Code

rchlfryn and others added 4 commits June 19, 2026 08:14
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>
@github-actions

Copy link
Copy Markdown
Contributor

Migration Safety Check

Found 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 cascade

Warning (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 cascade

Warning (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 cascade

Warning (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 cascade

Warning (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 cascade

Warning (line 142): DELETE keyword detected - review for data loss

FOREIGN KEY (\`_parent_id\`) REFERENCES \`galleries\`(\`id\`) ON UPDATE no action ON DELETE cascade

Warning (line 158): DELETE keyword detected - review for data loss

FOREIGN KEY (\`tenant_id\`) REFERENCES \`tenants\`(\`id\`) ON UPDATE no action ON DELETE set null

Warning (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 docs/migration-safety.md for guidance.

@rchlfryn rchlfryn changed the title Add media gallery with lightbox (#576) Add media gallery collection & block with lightbox Jun 19, 2026
@rchlfryn rchlfryn self-assigned this Jun 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Preview deployment: https://gallery-collection-576.preview.avy-fx.org

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant