acf_get_filesize()
acf_get_filesize
This function will return a numeric value of bytes for a given filesize string
Хуков нет.
Возвращает
(int).
Использование
acf_get_filesize( $size );
- $size
- .
По умолчанию: 1
Список изменений
| С версии 5.1.5 | Введена. |
Код acf_get_filesize() acf get filesize ACF 6.4.2
function acf_get_filesize( $size = 1 ) {
// vars
$unit = 'MB';
$units = array(
'TB' => 4,
'GB' => 3,
'MB' => 2,
'KB' => 1,
);
// look for $unit within the $size parameter (123 KB)
if ( is_string( $size ) ) {
// vars
$custom = strtoupper( substr( $size, -2 ) );
foreach ( $units as $k => $v ) {
if ( $custom === $k ) {
$unit = $k;
$size = substr( $size, 0, -2 );
}
}
}
// calc bytes
$bytes = floatval( $size ) * pow( 1024, $units[ $unit ] );
// return
return $bytes;
}