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

Gallery::prepare_image_html │ private │ WC 1.0

Sanitize a raw gallery <img>, apply the optional aspect-ratio crop, then normalize it for email rendering.

This is the single entry point every extraction path uses so image hardening (dropping the web-only class and reining in an oversized raw width) is applied consistently, whether the image is linked, unlinked, or cropped.

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

Хуков нет.

Возвращает

string. Prepared <img> HTML, or empty string when the image is invalid.

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

// private - только в коде основоного (родительского) класса
$result = $this->prepare_image_html( $raw_img_html, ?string $aspect_ratio, $cell_width, $image_attrs ): string;
$raw_img_html(строка) (обязательный)
Raw <img> HTML extracted from the block content.
?string $aspect_ratio(обязательный)
.
$cell_width(int) (обязательный)
Estimated display width of the gallery cell in px.
$image_attrs(массив) (обязательный)
Parsed attributes of the core/image block (id, sizeSlug, ...).

Код Gallery::prepare_image_html() WC 11.2.2

private function prepare_image_html( string $raw_img_html, ?string $aspect_ratio, int $cell_width, array $image_attrs ): string {
	$sanitized = Html_Processing_Helper::sanitize_image_html( $raw_img_html );
	$sanitized = $this->apply_aspect_ratio_crop( $sanitized, $aspect_ratio, $cell_width, $image_attrs );
	return $this->normalize_image_for_email( $sanitized, $cell_width );
}