Resolve every record image from the uploads folder
A bare image filename, whatever it belongs to (organization and event logos, people photos, team and award logos, backgrounds, hero photos, block images), now resolves to /uploads/<file>, in media.ts and for link previews in pageMeta.js. The per-kind public/ folders were guesses that don't exist. Only the site's own chosen assets, the NGU logos in the nav, footer and admin, stay bundled from src/assets/logos. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9eeb13c5ec
commit
dad3803ccc
6 changed files with 55 additions and 56 deletions
|
|
@ -1305,7 +1305,7 @@ const frontPage = {
|
|||
full: true,
|
||||
help:
|
||||
"A YouTube, Vimeo or Facebook link, or a video file: a filename in " +
|
||||
"/front-page/ or a link ending in .mp4 or .webm",
|
||||
"the uploads folder, or a link ending in .mp4 or .webm",
|
||||
},
|
||||
{ path: "video_title", label: "Video title", full: true, help: "Shown after \"Featured video\" above the headline" },
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
so the visitor presses play.
|
||||
|
||||
A featured video can also be a file rather than a link: a
|
||||
filename in public/front-page/, a /path, or an https URL ending
|
||||
filename in the uploads directory, a /path, or an https URL ending
|
||||
in a video extension. videoSource() says which, so the hero can
|
||||
hand a file to <video> and a link to an <iframe>.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
|
|
|||
|
|
@ -1,18 +1,25 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
MEDIA PATHS
|
||||
|
||||
Every image field in the API is a bare filename — "where the
|
||||
images live is the component's business", as history.js puts it.
|
||||
This is that business, in one file, so moving a directory is one
|
||||
edit rather than a grep.
|
||||
Every image field in the API is a filename or a path, and where a
|
||||
bare filename lives is decided here, in one file.
|
||||
|
||||
⚠ Only two of these directories are confirmed by the admin help
|
||||
text: people/. Event logos are uploads. The other three are a guess at
|
||||
your convention. Check public/ and fix them here — nothing else
|
||||
references the paths.
|
||||
One rule: record images are uploads. A value from the media
|
||||
library is already '/uploads/<file>'; a bare filename is a file
|
||||
copied into the uploads directory by hand (fall-retreat-logo.svg
|
||||
was), so it resolves to /uploads/<file> too. That covers logos,
|
||||
photos, backgrounds, hero slides, block images: everything an
|
||||
editor picks.
|
||||
|
||||
The site's own chosen assets (the NGU logos in the nav, footer
|
||||
and admin) are the exception: they're bundled from
|
||||
src/assets/logos and imported where they're used, not resolved
|
||||
here.
|
||||
|
||||
A value that already looks like a path or a URL is returned
|
||||
untouched, so a hand-written entry can point anywhere.
|
||||
server/src/pageMeta.js resolves images for link previews by the
|
||||
same rule; keep the two in step.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
const ABSOLUTE = /^(https?:|\/|data:)/
|
||||
|
|
@ -29,43 +36,42 @@ function inDir(dir: string) {
|
|||
}
|
||||
}
|
||||
|
||||
export const personPhoto = inDir('/people') // confirmed
|
||||
// Event logos are uploads. A bare filename is one copied into the
|
||||
// uploads directory by hand (fall-retreat-logo.svg was); anything
|
||||
// uploaded through the admin is already /uploads/…
|
||||
export const eventLogo = inDir('/uploads')
|
||||
export const eventBackground = inDir('/event-backgrounds')
|
||||
export const orgLogo = inDir('/org-logos') // ⚠ guess
|
||||
export const teamLogo = inDir('/team-logos') // ⚠ guess
|
||||
export const awardLogo = inDir('/award-logos') // ⚠ guess
|
||||
export const UPLOADS = '/uploads'
|
||||
|
||||
/* front_page_slides.media — the home page hero's photos. New with
|
||||
the Front page editor, which names the directory in its help. */
|
||||
export const heroPhoto = inDir('/front-page')
|
||||
const inUploads = inDir(UPLOADS)
|
||||
|
||||
/* front_page.video_url when it names a file rather than a link:
|
||||
same directory as the photos. */
|
||||
export const heroVideo = inDir('/front-page')
|
||||
/* One helper per field, all the same rule, so a caller says what the
|
||||
image is and a future exception is one line here. */
|
||||
export const personPhoto = inUploads
|
||||
export const eventLogo = inUploads
|
||||
export const eventBackground = inUploads
|
||||
export const orgLogo = inUploads
|
||||
export const teamLogo = inUploads
|
||||
export const awardLogo = inUploads
|
||||
|
||||
/* content_blocks.media, which can be an image on any owner's page,
|
||||
so it can't share a per-entity directory. */
|
||||
export const blockMedia = inDir('/media') // ⚠ guess
|
||||
/* front_page_slides.media, the hero's photos. */
|
||||
export const heroPhoto = inUploads
|
||||
|
||||
/* featured_cards.image, a card's own picture. Normally an upload
|
||||
('/uploads/…'); a bare filename looks here. */
|
||||
export const featuredImage = inDir('/featured')
|
||||
/* front_page.video_url when it names a file rather than a link.
|
||||
Videos can't be uploaded through the media library, so a file is
|
||||
one copied into the uploads directory by hand. */
|
||||
export const heroVideo = inUploads
|
||||
|
||||
/* blog_posts.cover_image and guest_photo. Normally uploads. */
|
||||
export const blogImage = inDir('/blog')
|
||||
/* content_blocks.media and content_block_items.media. */
|
||||
export const blockMedia = inUploads
|
||||
|
||||
/* featured_cards.image. */
|
||||
export const featuredImage = inUploads
|
||||
|
||||
/* blog_posts.cover_image and guest_photo. */
|
||||
export const blogImage = inUploads
|
||||
|
||||
/* ── By record kind ────────────────────────────────────────────
|
||||
The timeline sends `logo: { file, kind }` rather than a path,
|
||||
because v_timeline COALESCEs across five tables and only the
|
||||
ref_kind says which one the filename came from.
|
||||
|
||||
⚠ Three of these directories are the guesses above. Your current
|
||||
timelineRefs.ts already has the real ones — timeline logos render
|
||||
today — so copy them into the map above and delete this note.
|
||||
ref_kind says which one the filename came from. Featured cards
|
||||
send the same shape. Every kind resolves to the uploads directory
|
||||
today; the map is what lets one kind differ later.
|
||||
───────────────────────────────────────────────────────────── */
|
||||
|
||||
const BY_KIND: Record<string, (file?: string | null) => string | null> = {
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ import { eventBackground, eventLogo as eventLogoSrc, orgLogo as orgLogoSrc } fro
|
|||
const DEFAULT_ORG_LOGO = null;
|
||||
|
||||
/* An <img> that removes itself if the file 404s. `src` is already
|
||||
resolved by media.ts: an event logo from the uploads directory, an
|
||||
organization's from org-logos, anything with a path or URL as is. */
|
||||
resolved by media.ts: a bare filename from the uploads directory,
|
||||
anything with a path or URL as it is. */
|
||||
function Logo({ src, alt = "", className }) {
|
||||
const [failed, setFailed] = useState(false);
|
||||
if (!src || failed) return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue