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 block HTML error using featured image, fixed background, minimum height #41660

Closed
room34 opened this issue Jun 10, 2022 · 2 comments · Fixed by #41693
Closed

Cover block HTML error using featured image, fixed background, minimum height #41660

room34 opened this issue Jun 10, 2022 · 2 comments · Fixed by #41693

Comments

@room34
Copy link

room34 commented Jun 10, 2022

Description

When a cover block uses the featured image, is set to fixed background, and has a minimum height, the minimum height is ignored because the block is generating invalid HTML.

In this scenario, the front end <div class="wp-block-cover"> tag contains two style attributes. This is because the editor inserts style="min-height:nnnpx" with “Minimum height of cover”, and the cover.php file is inserting a second one, containing style="background-image:url(https://example.com/image.jpg)" with the preg_replace() call in lines 46-51. That preg_replace() call erroneously assumes there's not already a style attribute in the HTML tag.

This could be fixed either with a much more complex regular expression, or by adding a conditional that first checks for the presence of style=" in the string and then two different regular expressions.

Step-by-step reproduction instructions

  1. Create a Cover block.
  2. Set the block to “Use featured image”.
  3. Turn on “Fixed background” under “Media settings”.
  4. Set a “Minimum height of cover” under “Dimensions”.
  5. View the front end page.

Screenshots, screen recording, code snippet

No response

Environment info

WordPress 6.0. Not using Gutenberg plugin, but I've verified this code is unchanged in the latest release version of the plugin.

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@akasunil
Copy link
Member

I have fixed this issue in PR 41693. Request for review.

Thanks.

@room34
Copy link
Author

room34 commented Jun 15, 2022

Thanks! Looks to me like that should resolve the issue. I'm not authorized to review but I take it that will get sorted out so Im closing this issue.

@room34 room34 closed this as completed Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants