Phase 14d-3: frontend renders FileRepository uploads#31
Merged
Conversation
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
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.
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:headlineImage(Page)helper picks the first attachment in orderof preference:
FileRepository::findByItemAndFieldforPages.imagesfirst; the legacy
images[0]data array second. Returns the 1.x-style{name, path, title, position}dict theFrontend\ImageUrlBuilderconsumes — modern-file paths are normalised to
data/uploads-2.0/<itemDir>/so the builder doesn't rewrite them.resolveImagesField()caches thePages.imagesfield id per request.renderHero/renderArticleFigurego throughheadlineImage(nofunctional change for legacy-only pages).
Test plan
GET /articles/get-started-with-scriptor(before) → hero = legacy unsplashGET /articles/get-started-with-scriptor(after, cache flushed)→ hero =
1200x0_14d3-new.png(new file wins)GET /articles/→ article figure =800x350_14d3-new.png