MailPoet\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors
Blocks_Width_Preprocessor::convert_width_to_pixels()
Convert width to pixels
Method of the class: Blocks_Width_Preprocessor{}
No Hooks.
Return
float
.
Usage
// private - for code of main (parent) class only $result = $this->convert_width_to_pixels( $current_width, $layout_width ): float;
- $current_width(string) (required)
- Current width.
- $layout_width(float) (required)
- Layout width.
Blocks_Width_Preprocessor::convert_width_to_pixels() Blocks Width Preprocessor::convert width to pixels code WC 9.8.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; }