wp_convert_hr_to_bytes() WP 2.3.0
Converts a shorthand byte value to an integer byte value.
No Hooks.
Return
Int
. An integer byte value.
Usage
wp_convert_hr_to_bytes( $value );
- $value(string) (required)
- A (PHP ini) byte value, either shorthand or ordinary.
Changelog
Since 2.3.0 | Introduced. |
Since 4.6.0 | Moved from media.php to load.php. |
Code of wp_convert_hr_to_bytes() wp convert hr to bytes WP 5.7
function wp_convert_hr_to_bytes( $value ) {
$value = strtolower( trim( $value ) );
$bytes = (int) $value;
if ( false !== strpos( $value, 'g' ) ) {
$bytes *= GB_IN_BYTES;
} elseif ( false !== strpos( $value, 'm' ) ) {
$bytes *= MB_IN_BYTES;
} elseif ( false !== strpos( $value, 'k' ) ) {
$bytes *= KB_IN_BYTES;
}
// Deal with large (float) values which run into the maximum integer size.
return min( $bytes, PHP_INT_MAX );
}