Skip to content

Phase 14b-3: ImageUrlBuilder — on-demand thumbnails on iManager 2.0#22

Merged
bigin merged 1 commit into
imanager-2.0from
phase-14b3-images
May 3, 2026
Merged

Phase 14b-3: ImageUrlBuilder — on-demand thumbnails on iManager 2.0#22
bigin merged 1 commit into
imanager-2.0from
phase-14b3-images

Conversation

@bigin
Copy link
Copy Markdown
Owner

@bigin bigin commented May 3, 2026

Summary

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) — the static
imagePath() bridge from 14b-2 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.

Test plan

  • GET / 200, 7.3 KB (hero rendered with 1200×0 thumb)
  • GET /scriptors-demo-page 200, 7.3 KB
  • GET /articles/ 200, 7.1 KB (article list with 800×350 figure)
  • GET /articles/page2/ 200, 5.8 KB
  • GET /articles/get-started-with-scriptor 200, 7.4 KB (single article)
  • GET /contact 200, 7.1 KB
  • GET /this-does-not-exist 404
  • Thumbnails verified on disk + 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
    data/uploads-2.0/1.3.6/thumbnail/800x350_*.jpeg (782×350, aspect-preserved)
  • Browser smoke against ServBay

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.
@bigin bigin merged commit 7bcd62d into imanager-2.0 May 3, 2026
@bigin bigin deleted the phase-14b3-images branch May 15, 2026 05:24
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