Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cover: Avoid adding empty background image URL #49477

Merged
merged 1 commit into from
Mar 30, 2023

Conversation

Mamaduka
Copy link
Member

@Mamaduka Mamaduka commented Mar 30, 2023

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
Copy link
Contributor

@t-hamano t-hamano left a comment

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

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