Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks
Gallery::prepare_image_html
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.
Method of the class: Gallery{}
No Hooks.
Returns
string. Prepared <img> HTML, or empty string when the image is invalid.
Usage
// private - for code of main (parent) class only $result = $this->prepare_image_html( $raw_img_html, ?string $aspect_ratio, $cell_width, $image_attrs ): string;
- $raw_img_html(string) (required)
- Raw <img> HTML extracted from the block content.
- ?string $aspect_ratio(required)
- .
- $cell_width(int) (required)
- Estimated display width of the gallery cell in px.
- $image_attrs(array) (required)
- Parsed attributes of the core/image block (id, sizeSlug, ...).
Gallery::prepare_image_html() Gallery::prepare image html code WC 11.1.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 );
}