-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix image captions hiding rounded borders in galleries #45563
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,11 @@ function render_block_core_image( $attributes, $content ) { | |
$content = str_replace( '<img', '<img ' . $data_id_attribute . ' ', $content ); | ||
} | ||
} | ||
|
||
if ( isset( $attributes['border-radius'] ) ) { | ||
$content = str_replace( '<figure', "<figure style='border-radius:" . $attributes['border-radius'] . ";overflow:hidden;'", $content); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. despite the lines above using of note: if the function render_block_core_image( $attributes, $content ) {
if ( isset( $attributes[ 'data-id'] ) ) {
$tags = new WP_HTML_Tag_Processor( $content );
/*
* The data-id="$id" attribute on the img element provides
* backwards-compatibility for the gallery block, which now
* wraps image blocks within its inner blocks.
*
* @see the `render_block_data` hook in the core/gallery block
*/
if ( ! $tags->next_tag( 'img' ) ) {
break;
}
$tags->set_attribute( 'data-id', $attributes['data-id'] );
$content = (string) $tags;
}
if ( isset( $attributes['border-radius'] ) ) {
$tags = new WP_HTML_Tag_Processor( $content );
if ( ! $tags->next_tag( 'figure' ) ) {
break;
}
$style = $tags->get_attribute( 'style' );
$border = "border-radius: {$attributes['border-radius']}; overflow: hidden;";
$tags->set_attribute( 'style', "{$style}; {$border}" );
$content = (string) $tags;
}
return $content;
} |
||
} | ||
|
||
return $content; | ||
} | ||
|
||
|
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.
seems like it would make sense to check first if we're working with a gallery block before grabbing the theme json data as that might be the costlier step here.
Note here too a few styling issues. Some linter will probably also pick these up: