Last active
February 21, 2024 17:39
-
-
Save justintadlock/5804b6f7008dc7a77b85aa6f79eb70db to your computer and use it in GitHub Desktop.
Cover Block with a max-height block style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add to your theme's `functions.php` file. | |
// | |
// This block style has limited use cases to where you know | |
// what's going to be shown inside the Cover block. Often, | |
// setting a `max-height` is not a good idea when you have | |
// nested variable content. | |
// | |
// CSS `min-height` always overrules `max-height`, so this will | |
// only work if the `min-height` is lower than than the max. | |
// | |
// Set the `500px` value to your preferred limit. | |
add_action('init', function() { | |
register_block_style('core/cover', [ | |
'name' => 'max-height', | |
'label' => __('Limited Height', 'your-theme-slug'), | |
'inline_style' => '.wp-block-cover.is-style-max-height { | |
max-height: 500px; | |
}' | |
]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment