gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Gallery Lightbox border-radius flickers during zoom transition

Open YEAR93 opened this issue 2 months ago • 4 comments

When using the WordPress/Gutenberg Gallery Lightbox, images with a custom border-radius show a visual glitch during the Lightbox open and close animation.

I have a 28px border-radius applied to my gallery images:

.gb-container .wp-block-image img {
    border-radius: 28px;
}

The images look correct in the normal gallery view. I would expect the same rounded corners to remain visually consistent throughout the entire Lightbox zoom-in and zoom-out transition.

However, when opening or closing the Lightbox, the corners briefly distort/flicker. The effect is especially noticeable when the image transitions between the smaller gallery version and the larger Lightbox version.

What I expected

The gallery image and the Lightbox image should transition seamlessly between each other, with the border-radius remaining visually consistent throughout the animation.

For example:

Gallery → zoom into Lightbox → zoom back to Gallery

The corners should maintain the same visual shape without briefly becoming more square or otherwise changing during the transition.

What actually happens

The border-radius is correct in both the gallery and Lightbox states, but during the transition there is a subtle visual distortion/flicker.

Applying the same border-radius: 28px to both the gallery image and the Lightbox image reduces the issue, but does not completely resolve it:

.gb-container .wp-block-image img,
.wp-lightbox-overlay .wp-block-image img {
    border-radius: 28px;
}

The issue appears to be related to the fact that the original gallery image and the Lightbox image are separate elements and the Lightbox image is animated/scaled to transition between the two states.

Expected outcome

Ideally, the Lightbox transition should interpolate the image and its border-radius seamlessly so that the corners do not visibly change shape or flicker during the zoom animation.

This is particularly noticeable with larger fixed pixel border-radius values such as 28px.

Environment

  • WordPress
  • Gutenberg / WordPress Gallery block
  • Native WordPress Lightbox
  • Custom border-radius applied to gallery images

The issue was also reproduced by Gutenberg support, who suggested that the separate original and Lightbox image elements may be the underlying cause.

YEAR93 avatar Sep 08 '26 03:09 YEAR93

See related forum discussion: https://wordpress.org/support/topic/gutenberg-gallery-lightbox-border-radius-flickers-to-square-when-closing/

https://github.com/user-attachments/assets/91bf16b9-870e-405e-a52a-b30633a0074d

ramonjd avatar Sep 09 '26 07:09 ramonjd

Reproduction Report

Description

This report validates whether the issue can be reproduced.

Environment

  • WordPress: 7.2-beta1-64606-src (wordpress-develop local environment in Docker)
  • PHP: 8.3.32
  • Server: nginx/1.31.3
  • Database: MySQL 9.7.1
  • Browser: Chrome 155.0.8059.85
  • OS: Windows 11 Pro
  • Theme: Twenty Twenty-Five
  • MU Plugins: one test-only helper that prints the CSS below
  • Plugins: None activated

Steps

  1. Publish a post with a Gallery of three 800x533 images, each with "Expand on click" (lightbox) enabled.
  2. Add the CSS from the issue, in two variants:
    • A: .wp-block-gallery .wp-block-image img { border-radius: 28px; }
    • B: A plus .wp-lightbox-overlay .wp-block-image img { border-radius: 28px; }
  3. On the front end, click the first image and record every animation frame while the lightbox opens: the rendered width and transform scale of the lightbox images, and their computed border-radius. The on-screen radius is the computed radius times the scale.

Actual Results

In the gallery, the image is 202px wide with a 28px radius. When the lightbox opens, the image zooms from 203px to 800px with a CSS transform (scale 0.253 to 1, settling at 383 ms).

Variant On-screen corner radius during the zoom At the first frame (same size as the gallery image)
A: radius on the gallery image only 0px on every frame 0px instead of 28px
B: radius on the gallery and lightbox images 7.1px rising to 28px 7.1px instead of 28px
  1. ✅ Error condition occurs (reproduced).

Additional Notes

  • A: the lightbox images have no radius, so the rounded corners turn square at the moment the zoom starts.
  • B matches the reporter's "reduces it but does not resolve it": the radius is applied to an element that is scaled with a transform, so the corners shrink to about a quarter (28px × 0.253 = 7.1px) and then grow back as the zoom finishes.
  • The overlay holds two stacked images; both showed the same width, scale and radius on every frame.
  • Only the opening animation was measured, in Chrome. The closing animation and other browsers were not measured.
  • A possible direction, untested: animate the radius together with the scale (start at the source radius divided by the initial scale), or carry the source image's computed radius into the lightbox.

Supplemental Artifacts

Per-frame data for both variants is available on request.

Thanks @YEAR93 for the clear report.

AI assistance: Yes. I used Claude (Anthropic) to set up the test environment, run the tests and draft this report, and I reviewed the results before posting.

softglazee avatar Oct 23 '26 10:10 softglazee

Thanks @YEAR93 for reporting and @softglazee for the clear reproduction report!

Since the bug is now confirmed with detailed steps, could we remove the Needs Testing label so it can move forward for dev?

huzaifaalmesbah avatar Oct 28 '26 16:10 huzaifaalmesbah

Thank you for the response. And yes you can remove the Needs Testing label.

YEAR93 avatar Oct 28 '26 16:10 YEAR93