Skip to content

Min/max aspect ratios should be be rounded to a fixed nearest decimal #1765

@westonruter

Description

@westonruter

Looking at a site in the wild I see the following in the page source:

"minViewportAspectRatio":0.40000000000000002220446049250313080847263336181640625,"maxViewportAspectRatio":2.5

This is a laughable minViewportAspectRatio. Nevertheless, the values 0.4 and 2.5 are what show up in the source:

return (float) apply_filters( 'od_minimum_viewport_aspect_ratio', 0.4 );

return (float) apply_filters( 'od_maximum_viewport_aspect_ratio', 2.5 );

Aren't floating point numbers fun.

I'm not sure how having such a long decimal would be prevented, as the return value of the functions there is sent straight to be exported as JSON here:

$detect_args = array(
'minViewportAspectRatio' => od_get_minimum_viewport_aspect_ratio(),
'maxViewportAspectRatio' => od_get_maximum_viewport_aspect_ratio(),

wp_json_encode( $detect_args )

Not a big issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    Done 😃

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions