Image code: shared module for step and cover images #30

Closed
opened 2026-11-02 11:41:43 +01:00 by miko · 1 comment
Owner

Follow-up to #18 (PR #29), from its code review.

What

Since #18, step images and cover images share the upload pipeline, the guarded media route and the crop editor, but the shared code still lives under src/stepImages/ and is partly duplicated. Tidy it up without changing behaviour. See ADR-0006.

Acceptance criteria

  • Shared image code (files, storage, processImage, crop, cropForm, upload, href, access, CropDialog) moves from src/stepImages/ to its own module (e.g. src/images/); src/stepImages/ and src/coverImages/ keep only what is specific to them
  • recropStepImage and recropCoverImage share one re-crop flow (read crop → read original → render variants → swap row in a locked transaction → delete the loser's variants); only the row swap differs
  • One place maps a stored crop in both directions (DB columns ↔ {original, crop}), replacing cropFields, croppedImage/StoredImage in the guide edit page and the inline field lists in the re-crop actions
  • Clearer names: FILE_HINT vs. UPLOAD_HINT; call in the image editors
  • No behaviour change: existing tests pass, upload/re-crop/remove of step and cover images still work in the app

Out of scope / noticed

  • Deleting variants leaves an empty variants/<id>/ directory behind (diskStorage.delete); could be cleaned up here or separately.
  • coverTileImage always declares the medium variant as 960w, although variants are rendered without enlargement and a crop can be as small as 160 px.

Vocabulary: GLOSSARY.md. Decisions: docs/adr/.

Follow-up to #18 (PR #29), from its code review. ## What Since #18, step images and cover images share the upload pipeline, the guarded media route and the crop editor, but the shared code still lives under `src/stepImages/` and is partly duplicated. Tidy it up without changing behaviour. See ADR-0006. ## Acceptance criteria - [ ] Shared image code (`files`, `storage`, `processImage`, `crop`, `cropForm`, `upload`, `href`, `access`, `CropDialog`) moves from `src/stepImages/` to its own module (e.g. `src/images/`); `src/stepImages/` and `src/coverImages/` keep only what is specific to them - [ ] `recropStepImage` and `recropCoverImage` share one re-crop flow (read crop → read original → render variants → swap row in a locked transaction → delete the loser's variants); only the row swap differs - [ ] One place maps a stored crop in both directions (DB columns ↔ `{original, crop}`), replacing `cropFields`, `croppedImage`/`StoredImage` in the guide edit page and the inline field lists in the re-crop actions - [ ] Clearer names: `FILE_HINT` vs. `UPLOAD_HINT`; `call` in the image editors - [ ] No behaviour change: existing tests pass, upload/re-crop/remove of step and cover images still work in the app ## Out of scope / noticed - Deleting variants leaves an empty `variants/<id>/` directory behind (`diskStorage.delete`); could be cleaned up here or separately. - `coverTileImage` always declares the medium variant as `960w`, although variants are rendered without enlargement and a crop can be as small as 160 px. Vocabulary: GLOSSARY.md. Decisions: docs/adr/.
Author
Owner

Done in PR #36: shared image code now lives in src/images/, one re-crop flow (recropImage), one crop mapping (storedCrop), call/run renamed in the editors. The two out-of-scope notes (empty variant dirs, 960w in coverTileImage) are not addressed.

Done in PR #36: shared image code now lives in src/images/, one re-crop flow (recropImage), one crop mapping (storedCrop), call/run renamed in the editors. The two out-of-scope notes (empty variant dirs, 960w in coverTileImage) are not addressed.
miko closed this issue 2026-11-02 14:00:51 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MassiveDynamic/kataba#30
No description provided.