Image block: refactor and remove data-wp-body#58835
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: -912 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
|
It looks like this PR refactoring reduced the size of the JS code of the lightbox by 25% 🙂 |
|
This pull request changed or added PHP files in previous commits, but none have been detected in the latest commit. Thank you! ❤️ |
|
This is ready. We saw a couple of bugs in Safari that are already present in
|
SantosGuillamot
left a comment
There was a problem hiding this comment.
Great refactoring! 👏 Glad to see that we are sending less JS and HTML to the browser 🙂
I've been testing it on Chrome, Safari, iPhone, and Android, and everything seems to be working as previously.
…toggles Renders the inline caption inside the lightbox overlay (hidden since PR WordPress#58835 shipped in WordPress 6.5) and adds two Gallery-level toggles so authors can control where captions appear. Image block: - Extract caption in `block_core_image_render_lightbox()` and pass it to the Interactivity API state (plain text via `wp_strip_all_tags`). - Add a `<figcaption class="wp-lightbox-caption">` inside the overlay template, bound via `data-wp-text`. - New `block_core_image_apply_gallery_caption_visibility()` filter to strip the inline caption when the parent Gallery opts out. Gallery block: - New `showCaptionInGallery` and `showCaptionInLightbox` optional attributes exposed via `providesContext`. - New `Captions` section in the Settings panel with two toggles. Styles fade the overlay caption in after the zoom animation settles, with `prefers-reduced-motion` disabling the transition. This unblocks the WordPress.org Plugin Directory screenshot migration (WordPress/wordpress.org#524, meta#8083). A follow-up PR is planned for per-image overrides. Fixes WordPress#60469
What?
This PR removes the use of
data-wp-bodydirective in the Image block. It also refactors the logic a bit to clean up the code, and reduce the size of the JavaScript file.Why?
Because the Interactivity API won't include the
data-wp-bodydirective in the WP 6.5 version.How?
By replacing the
data-wp-bodywith awp_footerfilter that prints only one lightbox overlay for all the images.Testing Instructions