Skip to content

feat(portfolio): add design.aspect_ratio setting for card images#3333

Open
Vidminas wants to merge 1 commit into
HugoBlox:mainfrom
Vidminas:feat/portfolio-image-ratio
Open

feat(portfolio): add design.aspect_ratio setting for card images#3333
Vidminas wants to merge 1 commit into
HugoBlox:mainfrom
Vidminas:feat/portfolio-image-ratio

Conversation

@Vidminas

Copy link
Copy Markdown

Card image dimensions were hardcoded: a fixed-height box (h-48) plus a fixed 3:2 crop (Fill "600x400"). The box ratio therefore tracked card width / column count and rarely matched the crop, so object-cover re-cropped the already cropped image (a double-crop).

πŸš€ What type of change is this?

  • πŸ› Bug fix (A non-breaking change that fixes an issue)
  • ✨ New feature (A non-breaking change that adds functionality)
  • πŸ’… Style change (A change that only affects formatting, visuals, or styling)
  • πŸ“š Documentation update (Changes to documentation only)
  • 🧹 Refactor or chore (A code change that neither fixes a bug nor adds a feature)
  • πŸ’₯ Breaking change (A fix or feature that would cause existing functionality to not work as expected)

🎯 What is the purpose of this change?

Portfolio card image dimensions are hardcoded β€” a fixed-height box (h-48) plus a fixed 3:2
crop (Fill "600x400"). Two problems:

  1. There's no way to change the card image ratio without overriding the whole block.
  2. Because the box is a fixed height spanning the card width, its ratio tracks card width /
    design.columns and rarely equals the crop's 3:2, so object-cover re-crops the already
    cropped image (a double-crop).

This change adds a design.aspect_ratio knob whose named presets mirror the gallery
block's
existing design.aspect_ratio vocabulary, plus a photo (3:2) preset:

value box crop
square aspect-square 600Γ—600
landscape aspect-[4/3] 600Γ—450
portrait aspect-[3/4] 480Γ—640
wide aspect-[16/9] 800Γ—450
photo (default) aspect-[3/2] 600Γ—400

The chosen ratio drives both the CSS aspect box and the Fill dimensions from a single
map, so the box always matches the crop β†’ one predictable crop at any width (this is what also
resolves the double-crop). It defaults to photo (3:2, 600Γ—400), so sites that don't set it
render exactly as before β€” non-breaking. All aspect class strings are written literally in the
template so Tailwind's scanner generates them.

Verified on the dev-portfolio starter: with no config the cards render aspect-[3/2] boxes and
600Γ—400 images (unchanged); with design.aspect_ratio: wide they render aspect-[16/9] boxes
and 800Γ—450 images, and Tailwind emits the aspect-ratio: 16/9 rule.


πŸ“Έ Screenshots or Screencast (if applicable)

The fix β€” double-crop, shown at 2 columns where it's most severe:

Before β€” main, fixed-height h-48 box After β€” this PR, ratio box (default photo 3:2)
fix-before fix-after

At 2 columns the fixed-height box makes each image an ultra-wide letterbox that re-crops the 3:2
source (laptops sliced off top and bottom); the ratio box shows the full, intended 3:2 image.

The aspect_ratio presets (3 columns):

photo β€” 3:2 (default) wide β€” 16:9 square β€” 1:1
after-photo after-wide after-square

ℹ️ Documentation Check

  • No, this change does not require a documentation update.
  • Yes, I have updated the documentation accordingly (or will in a follow-up PR).

This PR updates the portfolio block's README.md: a aspect_ratio row in the Design-parameters
table and the option in the Basic-Usage example (noting it shares the gallery block's vocabulary).


πŸ“œ Contributor Agreement

Thank you for your contribution!

Card image dimensions were hardcoded: a fixed-height box (h-48) plus a fixed
3:2 crop (Fill "600x400"). The box ratio therefore tracked card width / column
count and rarely matched the crop, so object-cover re-cropped the already
cropped image (a double-crop).

Add a `design.aspect_ratio` knob (square | landscape | portrait | wide | photo)
that mirrors the gallery block's vocabulary and drives BOTH the CSS aspect box
and the Fill dimensions from one map, so the box always matches the crop β€” a
single, predictable crop at any width / column count.

Defaults to `photo` (3:2, 600x400), preserving the previous appearance, so it's
non-breaking. All aspect class strings are literal in the template so Tailwind's
scanner emits them. Documents the option in the block README.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Vidminas Vidminas requested a review from gcushen as a code owner July 10, 2026 09:27
@netlify

netlify Bot commented Jul 10, 2026

Copy link
Copy Markdown

βœ… Deploy Preview for academic-demo canceled.

Name Link
πŸ”¨ Latest commit 57d519b
πŸ” Latest deploy log https://app.netlify.com/projects/academic-demo/deploys/6a50bb0fe5d79700080ec034

@github-actions

Copy link
Copy Markdown
Contributor

Wow, your first PR! Welcome to the community! πŸŽ‰

Thank you for this contribution to open source and open research. It makes a huge impact for the thousands of innovators building with Hugo Blox.

If you're wondering about next steps, please read our Contributor Guide for coding standards, how to run the project locally, and how to get help.

We hope this is just the start of your journey with us. Let's build the future together! Join us on Discord to connect with the team and community.

Awesome work, we'll take a look soon! ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant