Gutenberg wp-cover block within custom patterns breaks
I'm creating custom patterns that have a cover block with column blocks inside (then content / heading, paragraph, buttons within those columns).
The background images used for the cover block consistently break in the production environment but not local. The images. are pulling from Dropbox so not an issue with the image source.
I'm getting the "this block contains unexpected ..." message in my production environment but not locally.
Here's an example of a pattern in my theme's functions.php file:
register_block_pattern (
'mytheme-sierra/mytheme-hero-pattern',
array(
'title' => __( 'Full height cover, heading and buttons', 'nrdly-sierra' ),
'categories' => array('headers'),
'keywords' => array('cover','image'),
'content' => '
<!-- wp:cover {"url":"https://www.dropbox.com/s/ko7su6thbibwpe4/c86b8baa.jpeg?raw=1","dimRatio":0,"align":"full","className":"hero"} -->
<div class="wp-block-cover alignfull hero"><img class="wp-block-cover__image-background" alt="" src="https://www.dropbox.com/s/ko7su6thbibwpe4/c86b8baa.jpeg?raw=1" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column -->
<div class="wp-block-column"><!-- wp:heading {"level":1} -->
<h1>Be a hero.</h1>
<!-- /wp:heading -->
<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button {"textColor":"white","className":"is-style-outline"} -->
<div class="wp-block-button is-style-outline"><a class="wp-block-button__link has-white-color has-text-color">Take action</a></div>
<!-- /wp:button -->
<!-- wp:button {"textColor":"white","className":"is-style-outline"} -->
<div class="wp-block-button is-style-outline"><a class="wp-block-button__link has-white-color has-text-color">Learn more</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons --></div>
<!-- /wp:column -->
<!-- wp:column -->
<div class="wp-block-column"></div>
<!-- /wp:column --></div>
<!-- /wp:columns --></div></div>
<!-- /wp:cover -->',
)
);
Locally, I see:
In production, I see:
If I "convert to HTML" in the production, I see the following:
<div class="wp-block-cover alignfull hero">
<img class="wp-block-cover__image-background" alt="" src="https://www.dropbox.com/s/ko7su6thbibwpe4/c86b8baa.jpeg?raw=1" data-object-fit="cover"/>
<div class="wp-block-cover__inner-container"></div>
</div>
WordPress information
- WordPress version: 5.7
- Gutenberg version: 10.2.1
- Are all plugins except Gutenberg deactivated? Yes
- Are you using a default theme (e.g. Twenty Twenty-One)? Yes (moved function to default theme to test there as well)
Device information
- Device: Desktop
- Operating system: iOS
- Browser: Chrome
Thank you!
I copied your pattern exactly, and tested both locally and on a live site.
Didn't get the invalid content/block recovery message. It worked perfectly in both environments.
Could it be some issue related to your production environment?
I suppose it could be. Hosting with Flywheel. I can reach out and see if they have any ideas.
@bradley2083 Thanks for reporting this! Based on the back and forth here, it seems like this can't be replicated. Looking over the pattern code you shared, all looks right to me too :D I'm going to close this out as a result but feel free to reopen if you learn anything more from Flywheel. Thanks so much.