Skip to content

Cover: Avoid adding empty background image URL - #49477

Merged
Mamaduka merged 1 commit into
trunkfrom
fix/cover-empty-background-url
Mar 30, 2023
Merged

Mamaduka merged 1 commit into
trunkfrom
fix/cover-empty-background-url

Conversation

@Mamaduka

@Mamaduka Mamaduka commented Mar 30, 2023 •

Copy link
Copy Markdown
Member

What?

This a follow-up to #49434 (comment).

Update the Cover block's render logic to return early when a post has no featured image and avoid processing the content markup.

Props @t-hamano for noticing this edge case.

Why?

There's no need to modify the Cover block's markup when a post has no featured image.

Testing Instructions

  1. Open a Post or Page.
  2. Add the featured image to the post from the Post panel
  3. Insert a cover block
  4. Enable "Fixed background" or "Repeated background"
  5. Delete the featured image from the Post panel.
  6. Confirm empty background-image:url() isn't rendered on front end.

Screenshots or screencast

CleanShot 2023-03-30 at 17 03 05

@Mamaduka
Mamaduka requested a review from ajitbohra as a code owner March 30, 2023 13:05
@Mamaduka Mamaduka self-assigned this Mar 30, 2023
@Mamaduka Mamaduka added [Type] Code Quality Issues or PRs that relate to code quality [Block] Cover Affects the Cover Block - used to display content laid over a background image labels Mar 30, 2023
@Mamaduka
Mamaduka requested review from t-hamano and removed request for ajitbohra March 30, 2023 13:06

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! I think an early return makes more sense than the code I suggested 😄

@github-actions

Copy link
Copy Markdown

Flaky tests detected in 694a107.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4564723775
📝 Reported issues:

@Mamaduka
Mamaduka merged commit dfdfaa3 into trunk Mar 30, 2023
@Mamaduka
Mamaduka deleted the fix/cover-empty-background-url branch March 30, 2023 13:42
@github-actions github-actions Bot added this to the Gutenberg 15.6 milestone Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Cover Affects the Cover Block - used to display content laid over a background image [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants