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

Product_Image::extract_image_width │ private │ WC 1.0

Extract image width from HTML for positioning calculations.

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

Хуков нет.

Возвращает

float. Image width in pixels.

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

// private - только в коде основоного (родительского) класса
$result = $this->extract_image_width( $image_html ): float;
$image_html(строка) (обязательный)
Image HTML.

Код Product_Image::extract_image_width() WC 11.2.2

private function extract_image_width( string $image_html ): float {
	$width = ( new Dom_Document_Helper( $image_html ) )->get_attribute_value_by_tag_name( 'img', 'width' ) ?? '';
	if ( $width ) {
		return Styles_Helper::parse_value( $width );
	}

	return 300;
}