You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Create a Cover block.
Set the block to “Use featured image”.
Turn on “Fixed background” under “Media settings”.
Set a “Minimum height of cover” under “Dimensions”.
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
The text was updated successfully, but these errors were encountered:
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 twostyle
attributes. This is because the editor insertsstyle="min-height:nnnpx"
with “Minimum height of cover”, and the cover.php file is inserting a second one, containingstyle="background-image:url(https://example.com/image.jpg)"
with thepreg_replace()
call in lines 46-51. Thatpreg_replace()
call erroneously assumes there's not already astyle
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
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
The text was updated successfully, but these errors were encountered: