gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Gutenberg wp-cover block within custom patterns breaks

Open bradhogan opened this issue 5 years ago • 3 comments

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:

Screen Shot 2021-03-22 at 10 25 06 AM

In production, I see:

Screen Shot 2021-03-22 at 10 26 09 AM

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!

bradhogan avatar Mar 22 '21 16:03 bradhogan

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?

Sandstromer avatar Mar 22 '21 18:03 Sandstromer

I suppose it could be. Hosting with Flywheel. I can reach out and see if they have any ideas.

bradhogan avatar Mar 22 '21 18:03 bradhogan

@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.

annezazu avatar May 17 '21 20:05 annezazu