Image Masking Proof of Concept

S3 Hub — Dr. Steven Teitelbaum | Extracting individual views from composite before/after grids

Step 1 — Source Image

The Original Composite (6-Panel Grid)

This is the single image as it exists in DatoCMS. It contains 6 views arranged in a 3×2 grid: top row is "Before" (front, 3/4, profile), bottom row is "After" (front, 3/4, profile).

Original 6-panel composite
Step 2 — CSS-Masked Individual Crops

Same Image, Six Different Masks

Each card below uses the exact same image URL — no server-side processing needed. CSS object-fit + object-position crops each panel. The image is scaled to 300% width and 200% height, then positioned to reveal only one cell of the 3×2 grid.

Before — Front
Before
Front
Before — 3/4
Before
3/4 View
Before — Profile
Before
Profile
After — Front
After
Front
After — 3/4
After
3/4 View
After — Profile
After
Profile

All 6 cards above load from one single image URL — zero additional server requests

Step 3 — Clean Thumbnail for Gallery Grid

One View as the Card Thumbnail

Instead of showing the full composite grid, the Hub gallery card shows just the "After — 3/4 View" as a clean, focused thumbnail. Click it to open the comparison slider.

Men's Facelift — After
Men's Face and Neck Lift
Tap to compare before & after →
How it works:

The thumbnail shows a single "After" crop using pure CSS — object-position: 50% 100% targets the center column, bottom row of the 3×2 grid.

No image processing needed. The browser loads the same DatoCMS image URL and CSS handles the crop client-side. DatoCMS even supports server-side cropping via URL parameters (?w=400&h=500&fit=crop&crop=bottom,center) if you want smaller payloads.

For the dev team: This can be defined as a Tresio component config — each gallery item stores its layout_type (6-panel, 2-panel, 4-panel) and the CSS crop map is applied automatically.
Step 4 — Before/After Comparison Slider

Interactive Before & After

When a patient clicks a thumbnail, they get this slider. Drag the handle to compare. Switch between viewing angles — all from the same single image.

After
Before
Before
After
◂ ▸
Bonus — 2-Panel Layout Support

Side-by-Side Images Work Too

Some gallery images use a simpler 2-panel layout (Before left, After right). The same CSS masking technique works — just with width: 200% instead of 300%.

Before
Before
Profile
After
After
Profile
Powered by S3 Hub — Studio 3 Marketing