Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks
Gallery::get_columns_from_attributes
Get the columns value from block attributes.
Method of the class: Gallery{}
No Hooks.
Returns
int. Number of columns (1-8).
Usage
// private - for code of main (parent) class only $result = $this->get_columns_from_attributes( $block_attrs ): int;
- $block_attrs(array) (required)
- Block attributes.
Gallery::get_columns_from_attributes() Gallery::get columns from attributes code WC 11.1.2
private function get_columns_from_attributes( array $block_attrs ): int {
$columns = $block_attrs['columns'] ?? 3;
// Clamp to the same 1-8 range the core gallery block allows, so the email doesn't
// silently render fewer columns than the author chose. A lower cap forced wide galleries
// into extra partial rows whose images then stretched to a size the author never set
// (e.g. a 6-column gallery clamped to 5 rendered 5 + 5 + 2, ballooning the trailing pair).
$columns = max( 1, min( 8, (int) $columns ) );
return $columns;
}