bp_media_format_size_units( $bytes, bool $post_string = false, $type = 'bytes' )
Format file size units
Description
Parameters
- $bytes
-
(Required)
- $post_string
-
(Optional)
Default value: false
Return
(string)
Source
File: bp-media/bp-media-functions.php
function bp_media_format_size_units( $bytes, $post_string = false ) { if ( $bytes >= 1073741824 ) { $bytes = number_format( $bytes / 1073741824, 0 ) . ( $post_string ? ' GB' : '' ); } elseif ( $bytes >= 1048576 ) { $bytes = number_format( $bytes / 1048576, 0 ) . ( $post_string ? ' MB' : '' ); } elseif ( $bytes >= 1024 ) { $bytes = number_format( $bytes / 1024, 0 ) . ( $post_string ? ' KB' : '' ); } elseif ( $bytes > 1 ) { $bytes = $bytes . ( $post_string ? ' bytes' : '' ); } elseif ( $bytes == 1 ) { $bytes = $bytes . ( $post_string ? ' byte' : '' ); } else { $bytes = '0'. ( $post_string ? ' bytes' : '' ); } return $bytes; }
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.