Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks

Post_Template::count_media_descendants │ private │ WC 1.0

Count the media elements (images and embeds) contained within an element.

Метод класса: Post_Template{}

Хуков нет.

Возвращает

int.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->count_media_descendants( $element ): int;
$element(DOMElement) (обязательный)
The element to inspect.

Код Post_Template::count_media_descendants() WC 11.2.2

private function count_media_descendants( \DOMElement $element ): int {
	$count = $element->getElementsByTagName( 'img' )->length;
	foreach ( array( 'video', 'audio', 'iframe', 'svg' ) as $tag_name ) {
		$count += $element->getElementsByTagName( $tag_name )->length;
	}
	return $count;
}