Phase 14b-3: ImageUrlBuilder — on-demand thumbnails on iManager 2.0#22
Merged
Conversation
Image rendering goes through a new Frontend\ImageUrlBuilder that wraps the iManager 2.0 ImageProcessor. The builder rewrites legacy 1.x upload paths (data/uploads/<itemDir>/) to the post-migration root (data/uploads-2.0/), generates W×H thumbnails on first request, and caches them next to the original under thumbnail/<W>x<H>_<file> — keeping the 1.x naming convention so existing thumbnails stay reachable without re-encoding. Frontend\Site exposes the builder as $site->images. BasicTheme's renderHero() and renderArticleFigure() call $site->images->url(...) with size hints (1200×0 for hero, 800×350 for article-list figure) instead of the static imagePath() bridge from 14b-2 — that helper is deleted. Frontend\Site::getBasePath() also gained a small fix: it now strips the segments path off the request URI in either form (with or without trailing slash) and always returns a path ending in /, so URLs built by concatenation against $this->images->url(...) don't collide with the leading slash of the asset path. Manual smoke (PHP built-in server, all 200 except the deliberate 404): GET / 7.3 KB GET /scriptors-demo-page 7.3 KB (home alt) GET /articles/ 7.1 KB (article list) GET /articles/page2/ 5.8 KB (paginated) GET /articles/get-started-with-scriptor 7.4 KB (single article) GET /contact 7.1 KB GET /this-does-not-exist 404 Generated thumbnails verified on disk + as 200 image/jpeg over HTTP: data/uploads-2.0/1.1.6/thumbnail/1200x0_*.jpeg (1200×463) data/uploads-2.0/1.3.6/thumbnail/1200x0_*.jpeg (1200×x) data/uploads-2.0/1.3.6/thumbnail/800x350_*.jpeg (782×350, scaleDown) Snapshot diff master vs imanager-2.0 is intentionally deferred to 14f (final acceptance) — the two branches now produce divergent asset URLs by design (uploads-2.0 + on-demand cache vs the 1.x data/uploads/.../thumbnail/ files), so a verbatim wget-r diff would flag known-good differences.
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
Image rendering goes through a new
Frontend\ImageUrlBuilderthat wraps theiManager 2.0
ImageProcessor. The builder rewrites legacy 1.x upload paths(
data/uploads/<itemDir>/) to the post-migration root (data/uploads-2.0/),generates W×H thumbnails on first request, and caches them next to the
original under
thumbnail/<W>x<H>_<file>— keeping the 1.x naming conventionso existing thumbnails stay reachable without re-encoding.
Frontend\Siteexposes the builder as$site->images. BasicTheme'srenderHero()andrenderArticleFigure()call$site->images->url(...)withsize hints (1200×0 for hero, 800×350 for article-list figure) — the static
imagePath()bridge from 14b-2 is deleted.Frontend\Site::getBasePath()also gained a small fix: it now strips thesegments path off the request URI in either form (with or without trailing
slash) and always returns a path ending in
/, so URLs built byconcatenation against
$this->images->url(...)don't collide with theleading slash of the asset path.
Test plan
GET /200, 7.3 KB (hero rendered with 1200×0 thumb)GET /scriptors-demo-page200, 7.3 KBGET /articles/200, 7.1 KB (article list with 800×350 figure)GET /articles/page2/200, 5.8 KBGET /articles/get-started-with-scriptor200, 7.4 KB (single article)GET /contact200, 7.1 KBGET /this-does-not-exist404data/uploads-2.0/1.1.6/thumbnail/1200x0_*.jpeg(1200×463)data/uploads-2.0/1.3.6/thumbnail/1200x0_*.jpegdata/uploads-2.0/1.3.6/thumbnail/800x350_*.jpeg(782×350, aspect-preserved)