Skip to content

Console: group image thumbnails into per-ratio tiles + crop editor overlay#656

Open
jirkamotejl wants to merge 14 commits into
masterfrom
CS-318-thumbnail-grouping
Open

Console: group image thumbnails into per-ratio tiles + crop editor overlay#656
jirkamotejl wants to merge 14 commits into
masterfrom
CS-318-thumbnail-grouping

Conversation

@jirkamotejl

@jirkamotejl jirkamotejl commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Reworks the Console image-detail thumbnails (files#show) into a row of per-aspect-ratio preview tiles and turns the crop editor into a modal overlay.

  • Grouping: generated crop thumbnails are grouped by aspect ratio and shown as a wrapping row of compact preview tiles. Each tile is a fixed-height (120px) cropped preview whose width follows the ratio, labelled above with the ratio in W×H form (e.g. 16×9), with a small crop button in the corner. A single collapsible "all generated thumbnails" list (native <details>) below the tiles lists every generated size (crop + non-crop).
  • Proximity clustering: near-duplicate aspect ratios (e.g. responsive breakpoint sizes ~16:9) are clustered by proximity (relative RATIO_TOLERANCE) instead of one tile per exact ratio. Each bucket is labelled with its cleanest reduced ratio.
  • Label hook: overridable Folio::File#thumbnail_ratio_label(ratio, thumbnail_size_keys) (default nil) lets a host app relabel groups (e.g. by on-site usage); without an override the tile shows the W×H ratio.
  • Crop overlay: clicking a tile's crop button opens the per-ratio crop editor (Cropper.js) as a modal — close via ESC / backdrop / Cancel. The save flow (PATCH → re-render the tile) is unchanged.
  • Preview URL fix: tile previews resolve their src through the same CDN / temporary-url rewriting the detail thumbnails use (Folio::S3.cdn_url_rewrite / temporary_url for doader placeholders), instead of a raw file.thumb(key).url that could be unreachable.
  • Crop persistence: a group's crop is written under every exact aspect ratio it contains, so later thumbnail regeneration keeps the crop instead of falling back to default gravity.
  • Perf: stale thumbnail uid cleanup moved to Folio::DestroyThumbnailUidsJob.

Reviewer notes

  • RATIO_TOLERANCE = 0.04 is provisional — pending design sign-off. It deliberately merges near-identical ratios while keeping visually distinct ones apart (e.g. 2:1 stays separate from 16:9). Real image sets still surface some non-canonical ratios (e.g. 12×7, 40×21) as their own tiles; whether/how to snap those to canonical ratios is the open design question.
  • The group label defaults to the aspect ratio; usage labelling (mapping sizes → "card/hero/…") is intentionally left to host apps via the thumbnail_ratio_label hook.

@jirkamotejl jirkamotejl requested a review from mreq June 25, 2026 08:36

@mreq mreq left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if (e.key === 'Escape' && this._isEditing()) this.cancelEditing()
}
document.addEventListener('keydown', this.escHandler)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tohle patri do ruby stimulus_controller action s @document viz. https://github.com/sinfin/folio/blob/feat/ids-only-console/.skills/folio-stimulus/SKILL.md#events

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Na tohle bychom meli zavest nejakou konvenci. Patri tohle vedle komponenty podobne jako sidecar assets? Za me asi jo, ale melo by to byt podlozene rozhodnuti.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

namespace pod Folio::Thumbnails::

Replace the per-ratio summary cards (representative preview + variant
count + per-card 'all thumbnails' detail) with a row of compact preview
tiles, each labelled by its aspect ratio (W×H) with a corner crop button
that opens the existing modal editor. A single 'all generated thumbnails'
disclosure now lists every size below the tiles.

Tile preview URLs are resolved through the same CDN / temporary-url
rewriting the detail thumbnails use, fixing broken (raw Dragonfly/doader)
previews. The group label still defaults to the W×H ratio and stays
overridable via Folio::File#thumbnail_ratio_label.
@jirkamotejl jirkamotejl changed the title Console: group image thumbnails by aspect ratio + crop editor overlay Console: group image thumbnails into per-ratio tiles + crop editor overlay Jul 1, 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.

2 participants