Skip to content

Global Styles: Add support to use Featured Image as background image#77412

Open
dhruvikpatel18 wants to merge 1 commit intoWordPress:trunkfrom
dhruvikpatel18:try/add-featured-image-support
Open

Global Styles: Add support to use Featured Image as background image#77412
dhruvikpatel18 wants to merge 1 commit intoWordPress:trunkfrom
dhruvikpatel18:try/add-featured-image-support

Conversation

@dhruvikpatel18
Copy link
Copy Markdown
Contributor

@dhruvikpatel18 dhruvikpatel18 commented Apr 16, 2026

Part of: #54336

What?

Adds a "Use Featured Image" option to the Background Image control, similar to the behavior available in the Cover block.

When selected, the control uses the post’s featured image as the background image and reflects it in both the inspector preview and the block rendering.

Why?

Currently, the Background Image control only allows selecting or uploading an image manually. However, other blocks like the Cover block already support using the post’s featured image directly.

Adding this option:

  • Improves consistency across blocks
  • Enhances usability for common workflows (e.g., using featured images for hero/background sections)
  • Reduces duplication (no need to re-select the same image)

Testing Instructions

  1. Open a post or page
  2. Ensure a Featured Image is set
  3. Insert a block that supports Background Image (e.g., Poetry block)
  4. Open the block inspector → Background settings
  5. Click on the Background Image control
  6. Select "Use featured image"

Screenshots or screencast

Screen.Recording.2026-04-16.at.12.54.43.PM.mov

Use of AI Tools

AI assistance Claude was used to help reason about Gutenberg data flow and implementation approach. All code and logic have been reviewed, tested, and validated manually.

@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label Apr 16, 2026
Comment on lines +285 to +288
// eslint-disable-next-line @wordpress/data-no-store-string-literals
const { getEditedPostAttribute } = select( 'core/editor' );
// eslint-disable-next-line @wordpress/data-no-store-string-literals
const { getMedia } = select( 'core' );
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Using string store access intentionally to avoid importing @wordpress/editor, which caused memory issues in this component due to heavy dependencies. This follows a pattern used in performance-sensitive areas of Gutenberg.

If there is a preferred or safer alternative to accessing this data without introducing performance overhead, guidance would be appreciated.

@dhruvikpatel18 dhruvikpatel18 marked this pull request as ready for review April 16, 2026 10:17
@github-actions
Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: [Package] Block editor.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions
Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dhruvikpatel18 <dhruvik18@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

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

Labels

[Package] Block editor /packages/block-editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant