Conversation
59c73f2 to
50441e4
Compare
50441e4 to
b31be21
Compare
b31be21 to
cb81dbe
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new dynamic Gutenberg block to display a post’s featured image caption and (optionally) image credit when using a block theme.
Changes:
- Registers a new
newspack/featured-image-captionblock (editor + server render). - Adds an editor UI for overriding the caption via a
customCaptionattribute. - Wires the block into block-theme-only registration paths (JS + PHP).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/blocks/index.js | Registers the new block and gates it behind block-theme-only registration. |
| src/blocks/featured-image-caption/index.js | Block registration metadata/settings (title, icon, keywords, edit component). |
| src/blocks/featured-image-caption/edit.js | Editor implementation: pulls featured image + derives caption/credit placeholder; supports custom override. |
| src/blocks/featured-image-caption/style.scss | Adds editor styling for the “no featured image” placeholder state. |
| src/blocks/featured-image-caption/block.json | Defines block name, attributes, context usage, and supports settings. |
| src/blocks/featured-image-caption/class-featured-image-caption-block.php | Server-side render callback for frontend output (caption + credit, or custom override). |
| includes/class-blocks.php | Loads the new block PHP implementation when a block theme is active. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <figcaption { ...blockProps }> | ||
| <span className="featured-image-caption-placeholder">{ __( 'Featured image caption.', 'newspack-plugin' ) }</span> | ||
| </figcaption> |
There was a problem hiding this comment.
The placeholder shown when no featured image is set does not match the PR testing instructions (it doesn’t prompt the user to add a featured image). Consider updating this placeholder copy to explicitly instruct the user to add/set a featured image so the editor state is self-explanatory.
| const { caption, credit } = useSelect( | ||
| select => { | ||
| if ( ! featuredImage ) { | ||
| return {}; | ||
| } |
There was a problem hiding this comment.
This new block adds logic to derive caption/credit from the featured image entity (and format credits) but there are no accompanying unit tests. Similar blocks in this repo have Jest/Testing Library coverage; consider adding tests for “no featured image”, “caption only”, “credit only”, and “caption + org credit” to prevent regressions.
All Submissions:
Changes proposed in this Pull Request:
Closes https://linear.app/a8c/issue/NPPD-1187/captioncredit-block-for-featured-images
This PR adds a featured image caption block when a block theme is active.
How to test the changes in this Pull Request:
Other information: