WPDev.one
Core Function
View Source on Trac ↗

wp_image_matches_ratio()

wp_image_matches_ratio( mixed $source_width, mixed $source_height, mixed $target_width, mixed $target_height )

Helper function to test if aspect ratios for two images match.

Parameters 4 required

Name / Type Description
$source_width
int

Width of the first image in pixels.

Required
$source_height
int

Height of the first image in pixels.

Required
$target_width
int

Width of the second image in pixels.

Required
$target_height
int

Height of the second image in pixels.

Required

Return Value

(bool)
True if aspect ratios match within 1px. False if not.

Function Information

Since Version
4.6.0
Source File
wp-includes/media.php
Advertisement