Skip to content

Conversation

@miguelpeixe
Copy link
Member

@miguelpeixe miguelpeixe commented Dec 8, 2025

All Submissions:

Changes proposed in this Pull Request:

NPPM-2398

This PR adds core lightbox and Jetpack's full-screen carousel support to incoming posts.

There's an existing bug that occurs when a distributed post image ID matches an existing image in the destination media library, causing the lightbox and carousel libraries to fetch the local image as the "larger" version.

The standard behavior when the attachment doesn't match anything locally is to render the URL from the markup, which is usually low resolution.

The proposed strategy is to set the expected attributes via filters. The libraries will read from them to render the original URL in high resolution.

Note: This PR also moves the block-specific functionality to a separate class, so it's no longer part of the main Content Distribution class.

How to test the changes in this Pull Request:

  1. While on trunk, make sure you have Jetpack's "Display images in a full-screen carousel gallery" toggled on:
image
  1. Distribute a post with the following blocks:
    1. Image block with the link set to "Enlarge on click"
    2. Gallery block
    3. Tiled Gallery block
  2. Publish and visit the incoming post
  3. Click on each image and confirm that it either renders a low-resolution image (compare with the original post lightbox/carousel behavior) or another image entirely (if it matched a local attachment ID)
  4. Inspect the markup and confirm the images lack srcset and several other attributes in comparison to the original post markup
  5. Checkout this branch, make content changes in the original post, and save to trigger an update to the payload
  6. Refresh the incoming post page and confirm the markup now includes additional image attributes
  7. Click on each image and confirm the lightbox and carousel render the original resolution

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@miguelpeixe miguelpeixe requested a review from Copilot December 8, 2025 18:54
@miguelpeixe miguelpeixe marked this pull request as ready for review December 8, 2025 18:54
@miguelpeixe miguelpeixe requested a review from a team as a code owner December 8, 2025 18:54
@miguelpeixe miguelpeixe self-assigned this Dec 8, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds core lightbox and Jetpack carousel support for distributed posts by enriching the media payload with additional metadata and implementing custom rendering filters on incoming posts. The changes also refactor block processor functionality into a dedicated Blocks class structure for better organization.

  • Refactors block processing logic from Content_Distribution class into new Blocks and Block_Processor classes
  • Adds Image_Block class to handle lightbox rendering and image attribute filtering for incoming posts
  • Enriches outgoing post media data with metadata, srcset, dimensions, title, and description fields

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
includes/content-distribution/blocks/class-blocks.php New class managing block processor registration and processing for outgoing/incoming blocks
includes/content-distribution/blocks/class-block-processor.php New class encapsulating individual block processor logic with callbacks
includes/content-distribution/blocks/class-image-block.php New class implementing custom lightbox rendering and image attribute filtering for distributed posts
includes/content-distribution/class-outgoing-post.php Enhanced media data collection with additional metadata fields (srcset, dimensions, title, description)
includes/content-distribution/class-incoming-post.php Updated to use refactored Blocks::process_incoming_block() method
includes/class-content-distribution.php Refactored to remove block processor methods and delegate to new Blocks class
tests/unit-tests/content-distribution/test-block-processor.php Updated test references from Content_Distribution to Blocks class

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@miguelpeixe miguelpeixe requested a review from Copilot December 8, 2025 19:30
@miguelpeixe miguelpeixe changed the title fix(content-distribution): Image block lightbox support fix(content-distribution): Image block lightbox and Jetpack carousel support Dec 8, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@leogermani leogermani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works!

@miguelpeixe miguelpeixe merged commit 90a85ac into trunk Dec 16, 2025
17 checks passed
@miguelpeixe miguelpeixe deleted the fix/image-lightbox-support branch December 16, 2025 14:50
@github-actions
Copy link

Hey @miguelpeixe, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

matticbot pushed a commit that referenced this pull request Jan 9, 2026
## [2.18.2-alpha.1](v2.18.1...v2.18.2-alpha.1) (2026-01-09)

### Bug Fixes

* **content-distribution:** Image block lightbox and Jetpack carousel support ([#285](#285)) ([90a85ac](90a85ac))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 2.18.2-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Jan 19, 2026
## [2.18.2](v2.18.1...v2.18.2) (2026-01-19)

### Bug Fixes

* **content-distribution:** Image block lightbox and Jetpack carousel support ([#285](#285)) ([90a85ac](90a85ac))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 2.18.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants