: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* This interface defines the available units that can be recognized in HTML and/or CSS dimensions.
* @see https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
* @package ampproject/amp-toolbox
* Font size of the parent, in the case of typographical properties like font-size, and font size of the element
* itself, in the case of other properties like width.
* x-height of the element's font.
* The advance measure (width) of the glyph "0" of the element's font.
* Font size of the root element.
* Line height of the element.
* 1% of the viewport's width.
* 1% of the viewport's height.
* 1% of the viewport's smaller dimension.
* 1% of the viewport's larger dimension.
* Set of known absolute units.
* Set of known relative units.
* Pixels per inch resolution to use for conversions.
* Convert a unit-based length into a number of pixels.
* @param int|float $value Value to convert.
* @param string $unit Unit of the value.
* @return int|float|false Converted value, or false if it could not be converted.
public static function convertIntoPixels($value, $unit)
return $value * self::PPI / self::CM_PER_IN;
return $value * self::PPI / self::CM_PER_IN / 10;
return $value * self::PPI / self::CM_PER_IN / 40;
return $value * self::PPI;
return $value * self::PPI / 6;
return $value * self::PPI / 72;
// No conversion needed for pixel values.