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

Post_Template::get_cell_width │ private │ WC 1.0

Estimate the rendered pixel width of a single grid cell's content area.

The layout width is split evenly across the columns and the per-cell padding is removed from both sides. Used to give each rebuilt image a concrete width attribute (the Outlook fallback) instead of the intrinsic file width, which Outlook would otherwise honor literally and blow the cell open.

Method of the class: Post_Template{}

No Hooks.

Returns

int. Cell content width in px (at least 1).

Usage

// private - for code of main (parent) class only
$result = $this->get_cell_width( $layout_width, $columns ): int;
$layout_width(int) (required)
Available layout width in px.
$columns(int) (required)
Number of columns (>= 2; a grid is only built for multi-column layouts).

Post_Template::get_cell_width() code WC 11.1.2

private function get_cell_width( int $layout_width, int $columns ): int {
	$cell_width = (int) floor( $layout_width / $columns ) - ( 2 * self::CELL_PADDING );
	return max( 1, $cell_width );
}