Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks
Media_Text::extract_media_from_html
Extract media content from the HTML block content.
Method of the class: Media_Text{}
No Hooks.
Returns
String. Media HTML content or empty string if not found.
Usage
// private - for code of main (parent) class only $result = $this->extract_media_from_html( $block_content ): string;
- $block_content(string) (required)
- Raw block content.
Media_Text::extract_media_from_html() Media Text::extract media from html code WC 10.7.0
private function extract_media_from_html( string $block_content ): string {
// Extract inner content from figure element (removing figure wrapper for email compatibility).
$media_content = '';
if ( preg_match( '/<figure[^>]*class="[^"]*\bwp-block-media-text__media\b[^"]*"[^>]*>(.*?)<\/figure>/s', $block_content, $matches ) ) {
$media_content = trim( $matches[1] );
}
return $media_content;
}