You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Lightbox trigger BUTTON is not visible on an Image lightbox when Picture Element is enabled #1805
I just found that Modern Image Formats prevents that button from ever being visible on hover when Picture Element is enabled. This is because of this CSS rule (source):
That rule would not be necessary if the BUTTON.lightbox-trigger wrapped the IMG, since hovering over the button could always then cause the SVG to be revealed:
Otherwise, maybe the better course for now would be to conditionally add that CSS from the Modern Image Formats plugin when the Picture Element setting is enabled and there is a Image block that has lightbox enabled.
I'm seeing something problematic with the Interactivity API logic here. It's adding some inline styles to the BUTTON which is causing it to get positioned off-screen:
right:-629px;
top:-405px;
When Picture Element is not enabled, it's adding this style instead:
right:16px;
top:16px;
The culprit is display: contents. If I make these changes then it works as expected:
And the addition of display:contents appears to be causing problems with that calculation. Also, the display:contents seems to be preventing the :hover pseudo-class from selecting the picture when it is hovered over.
But display:contents was added for a reason in #1307 to fix #1300.
Given all this, it doesn't seem like there is a quick fix which we can apply from our side.
Activity
SohamPatel46 commentedon Jan 20, 2025
Hello, I would like to work on this and fix it. Thanks !
westonruter commentedon Jan 20, 2025
I suppose there are two ways this could go. One, Gutenberg's CSS selector could be updated to remove the
img, something like this:Otherwise, maybe the better course for now would be to conditionally add that CSS from the Modern Image Formats plugin when the Picture Element setting is enabled and there is a Image block that has lightbox enabled.
For example, at
wp_footeryou could check ifhas_filter( 'render_block_core/image', 'block_core_image_render_lightbox' )and then print out that additional CSS if it is notfalse. You can see this filter is added when the lightbox appears on the page: https://github.com/WordPress/wordpress-develop/blob/7fe8f1cc6f2722d773c738bbe0811bef2a07756e/src/wp-includes/blocks/image.php#L67-L83westonruter commentedon Jan 23, 2025
It appears we can't fix this easily. See #1814 (comment):
adamsilverstein commentedon Jan 30, 2025
Interesting, maybe we can rethink how the button is placed in Gutenberg? It feels a bit fragile as is.
westonruter commentedon Jan 30, 2025
Coincidentally, this would all be resolved by switching to popover where the
BUTTONwraps theIMG(orPICTURE) in WordPress/gutenberg#68726felixarntz commentedon Jan 30, 2025
That's not necessarily the right solution though, per the conversation in WordPress/gutenberg#55513.
westonruter commentedon Jan 31, 2025
Here's an alternative which should solve the issue in Gutenberg while being more resilient to variations in markup.
This selector:
could be changed to:
and this will then work for both regular
IMGbut alsoPICTURE(even when it hasdisplay:contents).adamsilverstein commentedon Jul 20, 2025
Tried
&:has(img:hover) buttonin WordPress/gutenberg#70800adamsilverstein commentedon Sep 25, 2026
@westonruter Feel free to re-open if the upstream fix didn't resolve this issue.