Skip to content

Commit

Permalink
edit cover block regex for featured image WordPress#4
Browse files Browse the repository at this point in the history
  • Loading branch information
navigatrum authored Jun 15, 2022
1 parent 9be451c commit ee8fe32
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/block-library/src/cover/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ class="wp-block-cover__image-background"

/* Inserts the featured image between the (1st) cover 'background' `span` and 'inner_container' `div`,
and removes eventual withespace characters between the two (typically introduced at template level) */
$content = preg_replace(
'/(<span\b[^>]*wp-block-cover__background[\s|"][^>]*>.*<\/span>)\s*(<div\b[^>]*wp-block-cover__inner-container[\s|"][^>]*>)/U',
"$1$image$2",
$content,
1
);
$inner_container_start = /<div\b[^>]+wp-block-cover__inner-container[\s|"][^>]*>/U;
if ( 1 === preg_match( $inner_container_start, $content, $matches, PREG_OFFSET_CAPTURE ) {
list( $fullmatch, $offset ) = $matches[0];
$content = substr( $content, 0, $offset ) . $image_tag . substr( $content, $offset );
}
}
Expand Down

0 comments on commit ee8fe32

Please sign in to comment.