Skip to content

Phase 14d-3: frontend renders FileRepository uploads#31

Merged
bigin merged 1 commit into
imanager-2.0from
phase-14d3-frontend-files
May 3, 2026
Merged

Phase 14d-3: frontend renders FileRepository uploads#31
bigin merged 1 commit into
imanager-2.0from
phase-14d3-frontend-files

Conversation

@bigin
Copy link
Copy Markdown
Owner

@bigin bigin commented May 3, 2026

Summary

Closes the upload pipeline started in 14d-1/14d-2: a file uploaded
through the editor's FilePond widget now shows up as the public hero
BasicTheme:

  • new headlineImage(Page) helper picks the first attachment in order
    of preference: FileRepository::findByItemAndField for Pages.images
    first; the legacy images[0] data array second. Returns the 1.x-style
    {name, path, title, position} dict the Frontend\ImageUrlBuilder
    consumes — modern-file paths are normalised to
    data/uploads-2.0/<itemDir>/ so the builder doesn't rewrite them.
  • resolveImagesField() caches the Pages.images field id per request.
  • renderHero / renderArticleFigure go through headlineImage (no
    functional change for legacy-only pages).

Test plan

  • GET /articles/get-started-with-scriptor (before) → hero = legacy unsplash
  • POST upload via editor (200×100 PNG, item 3) → 200, fileId
  • GET /articles/get-started-with-scriptor (after, cache flushed)
    → hero = 1200x0_14d3-new.png (new file wins)
  • GET /articles/ → article figure = 800x350_14d3-new.png
  • All three thumbnails (300×300 / 800×350 / 1200×0) generated, all HEAD 200
  • Browser smoke against ServBay (drag-drop in editor → reload frontend → see new image)

Closes the upload pipeline started in 14d-1/14d-2: a file uploaded
through the editor's FilePond widget now shows up as the public hero
and article-list figure on the bundled basic theme. Migrated 1.x
images embedded in `Item.data.images` stay as a fallback so pages
that haven't been re-uploaded yet keep rendering exactly as before.

Frontend\Site additions:
  - $site->files       (FileRepository)  — for theme code that wants
                                            modern attachments.
  - $site->fileStorage (FileStorage)     — for absolute path / public
                                            url helpers.

BasicTheme:
  - new private headlineImage(Page) helper picks the first attachment
    in order of preference: FileRepository::findByItemAndField for
    Pages.images first; the legacy `images[0]` data array second.
    Returns the 1.x-style {name, path, title, position} dict the
    Frontend\ImageUrlBuilder consumes — modern-file paths are
    normalised to `data/uploads-2.0/<itemDir>/` so the builder doesn't
    rewrite them.
  - resolveImagesField() caches the Pages.images field id per
    request via FieldRepository::findByName; pages categories
    without an `images` field fall straight back to legacy.
  - renderHero / renderArticleFigure now go through headlineImage
    (no functional change for legacy-only pages).

Manual smoke (PHP built-in server):
  GET /articles/get-started-with-scriptor       hero = legacy
                                                unsplash.jpeg
  POST /editor/api/upload (200×100 PNG, item 3) 200; fileId=4
  Cache flushed, GET /articles/get-started      hero = new file
                                                 (1200x0_14d3-new.png)
  GET /articles/                                article figure = new
                                                 file (800x350)
  Thumbnails 300x300 / 800x350 / 1200x0 generated, all reachable HEAD 200
@bigin bigin merged commit 18c49d2 into imanager-2.0 May 3, 2026
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