mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-08 03:00:14 +00:00
Media: Improve handling of cases where an uploaded image matches exactly a defined intermediate size. In most of these cases the original image has been edited by the user and is "web ready", there is no need for an identical intermediate image.
Introduces the `wp_image_resize_identical_dimensions` filter so plugins and themes can determine whether a new image with identical dimensions should be created, defaults to false. Props wpdennis, HKandulla, galbaras, azaozz. See #32437. git-svn-id: https://develop.svn.wordpress.org/trunk@46077 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -7316,3 +7316,19 @@ function is_wp_version_compatible( $required ) {
|
||||
function is_php_version_compatible( $required ) {
|
||||
return empty( $required ) || version_compare( phpversion(), $required, '>=' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two numbers are nearly the same.
|
||||
*
|
||||
* This is similar to using `round()` but the precision is more fine-grained.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*
|
||||
* @param int|float $expected The expected value.
|
||||
* @param int|float $actual The actual number.
|
||||
* @param int|float $precision The allowed variation.
|
||||
* @return bool Whether the numbers match whithin the specified precision.
|
||||
*/
|
||||
function wp_fuzzy_number_match( $expected, $actual, $precision = 1 ) {
|
||||
return abs( (float) $expected - (float) $actual ) <= $precision;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user