-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: Merge block and global styles #49434
Conversation
if ( isset( $attributes['minHeight'] ) ) { | ||
$height_unit = empty( $attributes['minHeightUnit'] ) ? 'px' : $attributes['minHeightUnit']; | ||
$height = " min-height:{$attributes['minHeight']}{$height_unit}"; | ||
|
||
$styles .= $height; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The min-height
is already serialized in the content. So there's no need to add it separately now that the style
attribute values are merged.
P.S. We might implement this via the dimensions
support flag. See #45300.
Flaky tests detected in b8278ba. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4553455959
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$styles = $processor->get_attribute( 'style' ); | ||
$merged_styles = ! empty( $styles ) ? $styles . ';' : ''; | ||
$merged_styles .= 'background-image:url(' . esc_url( $current_featured_image ) . ');'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$styles = $processor->get_attribute( 'style' ); | |
$merged_styles = ! empty( $styles ) ? $styles . ';' : ''; | |
$merged_styles .= 'background-image:url(' . esc_url( $current_featured_image ) . ');'; | |
$styles = $processor->get_attribute( 'style' ); | |
$merged_styles = ! empty( $styles ) ? $styles . ';' : ''; | |
if ( $current_featured_image ) { | |
$merged_styles .= 'background-image:url(' . esc_url( $current_featured_image ) . ');'; | |
} |
Maybe this should be done as a follow-up PR, but how about preventing the background-image
property with an empty url from being output when there is no post featured image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Let's do this in a follow-up 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, there's no need for that. You can't enabled a fixed background if if the featured image isn't set. So this code is never executed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the following steps could happen:
- Add the featured image to the post from the Post panel
- Insert a cover block
- Enable "Fixed background" or "Repeated background"
- Delete the featured image from the Post panel
After this procedure, the media settings will not appear in the cover block, but the hasParallax
or isRepeated
attributes will be retained.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Never trust the user 😄
I've changed on a local branch and will push it shortly.
What?
Fixes #49384.
PR adds missing dimension styles when using a Cover block as a featured image with a fixed background.
Why?
The render function was replacing the already generated styles attribute.
How?
I've updated the logic to merge styles before re-applying them.
Testing Instructions
Screenshots or screencast