Skip to main content

Images and Media

Where media lives

Media Location Served from
Photos, logos, icons, placeholders public/images/** (committed) Site origin
CMS uploads public/images/events, public/images/staff, public/images/sponsors Site origin
Explore the Fort videos (and optional posters/captions) R2 bucket, video/… https://cdn.r2.fortadams.org
Strategic Plan and Annual Report PDFs R2 bucket, documents/… https://cdn.r2.fortadams.org

next/image with static export

next.config.ts sets images.loader: "custom" with loaderFile: ./src/lib/image-loader.ts, and dangerouslyAllowSVG: true (with contentDispositionType: "attachment") for the placeholder SVGs.

The loader:

  • Default: returns src unchanged. Local and remote URLs pass through at original size.
  • With NEXT_PUBLIC_CF_IMAGE_BASE: absolute URLs become ${base}/cdn-cgi/image/width=W,quality=Q,format=auto/${src}, giving real responsive srcset through Cloudflare Image Resizing. The zone must have Image Resizing enabled. Local /images/... paths still pass through.

Because local images aren't resized, optimise them before committing: use WebP or JPEG at appropriate dimensions. Several legacy assets are large WordPress exports; see the size guidelines in Administrator Guide → Working with Images.

FortImage

Use FortImage instead of next/image whenever a source may be empty or may fail (CMS uploads, remote images). It falls back to /images/placeholders/fort-fallback.svg.

Explore the Fort media

  • Records live in src/lib/explore-fort.ts: id, location, title, description, videoPath (relative, URL-encoded), optional posterPath, captionsPath and transcript, and marker x/y as percentages on /images/explore/fort-adams-explore-map.webp. The same map is used by the History page.
  • A build-time validator enforces exactly six entries with unique IDs, required fields, and coordinates from 0 to 100.
  • Base URL: NEXT_PUBLIC_FORT_MEDIA_BASE, defaulting to https://cdn.r2.fortadams.org.

R2 / custom-domain requirements

This is configured on the R2 bucket or custom domain, not in Pages _headers:

  • MP4 byte-range responses (seeking and iOS playback) with Content-Type: video/mp4
  • text/vtt for caption files
  • Long-lived immutable cache headers. Version file names when replacing media, because caches won't see an overwrite.
  • CORS allowing the site origin to fetch video, poster, and caption files (captions via <track> need CORS)

Replacing or adding media

  • Swap a video: upload the new file to R2 under a new name, update videoPath, and deploy.
  • Move a marker: adjust x/y in explore-fort.ts. Recent commits did this iteratively; check it visually on desktop.
  • New PDF: upload to R2 documents/ and update the link in src/app/about/page.tsx.