Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors
Blocks_Width_Preprocessor::convert_width_to_pixels
Convert width to pixels
Метод класса: Blocks_Width_Preprocessor{}
Хуков нет.
Возвращает
float.
Использование
// private - только в коде основоного (родительского) класса $result = $this->convert_width_to_pixels( $current_width, $layout_width ): float;
- $current_width(строка) (обязательный)
- Current width.
- $layout_width(float) (обязательный)
- Layout width.
Код Blocks_Width_Preprocessor::convert_width_to_pixels() Blocks Width Preprocessor::convert width to pixels WC 11.2.2
private function convert_width_to_pixels( string $current_width, float $layout_width ): float {
$width = $layout_width;
if ( strpos( $current_width, '%' ) !== false ) {
$width = (float) str_replace( '%', '', $current_width );
$width = round( $width / 100 * $layout_width );
} elseif ( strpos( $current_width, 'px' ) !== false ) {
$width = $this->parse_number_from_string_with_pixels( $current_width );
}
return $width;
}