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

Media_Text::get_media_width_from_attributesprivateWC 1.0

Get the media width value from block attributes.

Method of the class: Media_Text{}

No Hooks.

Returns

Int. Media width percentage (1-99).

Usage

// private - for code of main (parent) class only
$result = $this->get_media_width_from_attributes( $block_attrs ): int;
$block_attrs(array) (required)
Block attributes.

Media_Text::get_media_width_from_attributes() code WC 10.8.1

private function get_media_width_from_attributes( array $block_attrs ): int {
	$media_width = $block_attrs['mediaWidth'] ?? 50;

	// Ensure the width is within reasonable bounds.
	$media_width = max( 1, min( 99, (int) $media_width ) );

	return $media_width;
}