Small SEO Tools

How to Keep an Off-Center Subject Visible in an Image Card

A photograph can load correctly while its subject disappears from a square card. If the source image still contains the subject, inspect the card’s CSS framing before exporting another file. A centered crop may be showing the wrong part of the picture.

This walkthrough uses a simple graphic with a red marker near its right edge. It changes the image’s position inside its CSS box while keeping the delivered file unchanged.

Compare the source image with its displayed box

Open the actual file used by the card and confirm that the important detail is present. Load that copy in the Image Resizer and read Original size and the Width and Height fields. This dimension check does not require a resize or export.

Our original test PNG is 600 by 400, a 3:2 image. The current resizer loads those dimensions. In the page, the example image element has a 200 by 200 CSS-pixel box. Those proportions differ, even though both dimensions of the source file are correct.

Inspect the image element in browser developer tools. Check its rendered width, height, active object-fit and object-position rules. If a publishing system already delivered a cropped file with the subject missing, CSS cannot recover pixels that are absent from that file.

Keep the image ratio while filling the card

For the synthetic test image, the markup is:

<img class="card-image"
     src="/images/framing-test.png"
     width="600" height="400"
     alt="Blue test image with a red marker near the right edge">

Give this example a fixed square display box:

.card-image {
  display: block;
  width: 200px;
  height: 200px;
  object-fit: cover;
  object-position: center center;
}

MDN’s object-fit reference explains that cover preserves the content’s ratio while filling its box, clipping overflow when the ratios differ. Here, the 600 by 400 graphic scales to 300 by 200 inside a 200 by 200 box. Centering clips 50 CSS pixels from each horizontal side.

The red marker sits near the source’s right edge, so it falls outside that centered square. Making a larger copy with the same composition would not choose a different part of the image for this CSS box.

Align the crop toward the important detail

For this right-edge marker, change the positioning rule:

.card-image {
  object-position: right center;
}

The image content’s right edge now aligns with the box’s right edge, retaining the right-hand part of the source. MDN’s object-position reference describes this alignment separately from the fitting rule. The property changes the painted framing; it does not rewrite or export the image file.

We tested the current resizer code locally in Chrome to read the original dimensions, then displayed the same PNG bytes in four native image elements. An independent decoder inspected the source marker and the rendered screenshot:

Image box in CSS pixels Object position Red marker visible
200 by 200 center center No
200 by 200 right center Yes
300 by 200 center center Yes
300 by 200 right center Yes

The two 300 by 200 controls match the source ratio, so there is no horizontal overflow to reframe. Their complete screenshot crops were identical. These are observations from one synthetic graphic and two fixed box ratios, not a subject detector or a guarantee for every photograph.

Review each card shape before saving the rule

  1. Choose the position for the particular image. A rule that preserves a subject on the right can hide something important on the left.
  2. Check every card shape used by the layout, including narrower mobile states. The cropped area changes when the box ratio changes.
  3. Inspect the actual image request and the saved computed styles. Confirm that the intended source and positioning rule survived the template or CMS.
  4. Read the image in its page context. Keep appropriate alternative text, and make sure essential information is available to readers.

If the entire graphic must remain visible, change the fitting or layout requirement rather than forcing a crop. The resizing and crop-or-padding guide explains the separate file-preparation decision. Use the alt-text guide to check the image’s role and description. Save the source image so a later layout can use a different composition.