AMP_Base_Sanitizer::sanitize_dimension

AMP_Base_Sanitizer::sanitize_dimension( string $value,  string $dimension )

Description #

Sanitizes a CSS dimension specifier while being sensitive to dimension context.


Parameters #

$value

(string) (Required) A valid CSS dimension specifier; e.g. 50, 50px, 50%. Can be 'auto' for width.

$dimension

(string) (Required) Dimension, either 'width' or 'height'.


Return #

(float|int|string) Returns a numeric dimension value, 'auto', or an empty string.