-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image captions in galleries hide rounded border #43586
Comments
I remember we struggled with this when we converted the Gallery to nested Image blocks, before you could set the border radius, but with the Rounded style, and the only solution we could find at the time was to move the caption when the rounded style was set: Would be good to revisit this as that is not such a good solution when there is only a subtle radius. |
It looks like this could be addressed by adding |
Hi, @ramonjd did |
Thanks for testing again @sharukhkhanajm Sorry, I'm not sure what I was looking at before, but yeah, I wonder if it's possible to always force the caption to sit under the image. Here's what I'm seeing when I apply border radius to the image in the block editor (and not via theme.json) I'm not sure how to get around this. Maybe we could try to apply the border radius value to the bottom of the |
Yes, that seems like a hack with current HTML. |
Just did some testing on this and couldn't get it to work with However, when adding the For this to be implemented we'd need to add the same border radius to the wrapping |
I can take a closer look into this. |
Appreciate everyone jumping in to work through this issue 👍 After digging into this further today, I believe this issue is a touch more complex than it may appear. The image block applies its global styles for borders (including radius) to the It's also worth noting that even if the
When applying borders at the individual image block level (not via theme.json/global styles), an additional CSS class is applied to the image block so the gallery styles can hook onto that and move the caption below the image. Captions have recently been added to the Elements API however, I don't believe they currently can alter the absolute positioning of the caption elements applied by the gallery styles. Perhaps we could create a gallery block style or setting that toggles off the absolutely positioned/overlaid captions? In earlier iterations of the gallery block refactor, it was tried to apply the border-radius to the bottom corners of a gallery image's caption. Unfortunately, this doesn't work well as the caption has different dimensions resulting in corner curves on the caption that don't match the image's. It might be possible to make the caption take up the same dimensions as its related image. Then its radii would match the image's. This approach might introduce other issues, such as interfering with clicks if the image is a link etc, so needs testing. Note also that this wouldn't address the problem of clipping captions if there is a large border radius and the text goes close enough to the edge. Applying the border-radius to the Hopefully that helps or sparks some fresh ideas! |
Thank you @aaronrobertshaw for the guidance and ideas!
This sounds good to me. As a user, I would want and expect captions to be able to show up underneath my image if I had configured it to have a large border radius. Empowering users to toggle the position of captions seems like the right approach. I can take all of the feedback and ideas so far and try to get something workable so we have something to look at. Would also love to hear further ideas and suggestions! |
So I was speaking with @mtias about this issue, and we think that giving users the option to modify this style globally would probably be the best move. However, global block styles are not something that have been implemented on the dev side yet. On the design side, there has been some initial exploration on what global block style variations might look like here: #44417 With all of this in mind, I don't believe there's a simple CSS fix for this unfortunately, which would just introduce different bugs. The right approach seems to me to figure out how we might introduce preset styles for gallery captions at the global level, which appears to me to need a bit more design exploration. I'm going to unassign this issue from myself and close the related in-progress pull request, and perhaps revisit this issue in the future. |
Landing randomly on this one today, I noticed something had changed. Specifically, if you create a gallery, where images do not have a border radius, add captions, and then proceed to add a border radius, the caption is now bumped outside, below: While I'm a fan of the option to show captions outside (see also #56587), it's not clear to me whether this behavior is intentional or not. I'd tend to echo another commenter, that the corner here should likely involve overflow handling of the caption style. |
From what I can tell, this is the intended behavior and is related to #31366. With this change, it looks like the caption will now be moved below the image when it has a border in addition to the Rounded style. @aaronrobertshaw might know more about this. |
Thanks for the ping 👍
Yes, it was intended and has been this way since the addition of border support for images back in 2022. My earlier comment on this issue provides a more detailed explanation on some of the edge cases with image borders against the gallery block's overlay caption styles. The only suggestions I had then for quick wins (but not proper solutions) were:
This tended to result in caption text getting clipped and led to the gallery refactor landing on relocating the caption. If the radius was also applied to the caption element itself, due to different dimensions the radius diverged from the image's. |
Description
When an Image block within a Gallery has a
border-radius
, the caption background obscures the bottom corners of the Image. The<figcaption>
element'sbottom-border-left-radius
andbottom-border-right-radius
should inherit from the Image block.Step-by-step reproduction instructions
Add a border radius to the Image block via
theme.json
:Test by adding a Gallery block with at least one image that has a caption.
Screenshots, screen recording, code snippet
Gallery shows an image with caption and one without:
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: