Repository navigation
feat(gallery): photo credits on galleries and carousels - #154
Closed
RonanHevenor wants to merge 1 commit into
Closed
RonanHevenor wants to merge 1 commit into
RonanHevenor wants to merge 1 commit into
Conversation
Empty placeholder commit so a pull request can be opened before any code exists. Will be replaced or built on as the actual change lands. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Member
Author
|
Superseded by #155 — this PR was auto-closed when its head branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Photo galleries and carousels carried no credit at all, and the
captionfield their blocks already declared was never rendered. Both blocks now take acreditrelationship, mirroring the one the inlineuploadnode has had since20260322— "Overrides the photographer set on the media record."Credit resolves per photo in the same order the upload node uses: an explicit block credit → the media record's
photographer→ itswriteInPhotographerfree text.creditishasMany, so a co-shot frame credits everyone at once on one line — "A, B, C/The Polytechnic" — with a single suffix, each staff name linking to its profile. Write-ins render bare, since they aren't staff.The two blocks diverge
Galleries no longer take a caption at all; the field is gone from the block, so it can't be entered.
Important
Captions already stored in published gallery blocks stop rendering, and Payload drops them the next time an editor saves that article.
PhotoGallerystripscaptionrather than merely ignoring it, so text saved before the field was removed can't resurface, and the sampled area matches exactly what's drawn.Placing a credit on a photograph
Because a gallery credit sits on the image,
lib/imageLuminance.tsdecides both where it goes and what colour it is from the pixels it will actually cover.It reconstructs the caption's own box — the same
12px/18px/px-4 pt-2 pb-3geometry the component renders with, wrapped to an estimated line count — in each bottom corner, and samples only those two rectangles.text-shadowto hold an edge.Measured on seed images at 3 columns:
Sampling the text's own rectangle rather than the whole image changes the answer in practice: playhouse averages 129 across the frame but 212 in the corner the credit lands in, so it's the one that reads black.
Column width is viewport-relative, so sampling assumes a 1280px reference. Narrower viewports wrap to more lines and cover more of the photo, which only ever makes the measured rectangle a subset of the real one. Legacy-archive rows have no local file to sample and fall back to white, bottom-left.
Migration
None, and that was verified rather than assumed.
Lexical block fields serialize into the existing
jsonbrichText columns — there are nophoto_galleryorcarouseltables and no new column. Confirmed by applyingmigrations/to a fresh database withPAYLOAD_DISABLE_PUSH=1andNODE_ENV=production, then writing and reading back a multi-credit gallery.pnpm generate:typesis likewise a no-op, since lexical blocks don't surface inpayload-types.ts.Scope
Both block definitions are mirrored in
payload.config.tsandcollections/LiveArticles.ts, so live-article updates get the same treatment — they already render through the sameSerializeLexicalpath.Checks
pnpm typecheckclean.pnpm lint0 errors (53 pre-existingmigrations/warnings, unchanged).🤖 Generated with Claude Code