diff --git a/wire/core/FileValidatorModule.php b/wire/core/FileValidatorModule.php index 86aa38f0..8e671ff5 100644 --- a/wire/core/FileValidatorModule.php +++ b/wire/core/FileValidatorModule.php @@ -10,7 +10,7 @@ * 3. Copy the getModuleInfo() method out of this class and update as appropriate. * 4. Implement an isValidFile($filename) method, and you are done. * - * EXAMPLE: /site/modules/FileValidatorSVG.module + * EXAMPLE: /site/modules/FileValidatorHTML.module * * class FileValidatorHTML extends FileValidatorModule { * public static function getModuleInfo() { diff --git a/wire/core/Functions.php b/wire/core/Functions.php index c826a20c..852cbf20 100644 --- a/wire/core/Functions.php +++ b/wire/core/Functions.php @@ -694,12 +694,14 @@ function wireIconMarkupFile($filename, $class = '') { * - `decimal_point` (string|null): Decimal point character, or null to detect from locale (default=null). * - `thousands_sep` (string|null): Thousands separator, or null to detect from locale (default=null). * - `small` (bool): If no $small argument was specified, you can optionally specify it in this $options array. + * - `type` (string): To force return value as specific type, specify one of: bytes, kilobytes, megabytes, gigabytes; or just: b, k, m, g. (3.0.148+ only) * @return string * */ function wireBytesStr($bytes, $small = false, $options = array()) { $defaults = array( + 'type' => '', 'decimals' => 0, 'decimal_point' => null, 'thousands_sep' => null, @@ -714,19 +716,20 @@ function wireBytesStr($bytes, $small = false, $options = array()) { $options = array_merge($defaults, $options); $locale = array(); + $type = empty($options['type']) ? '' : strtolower(substr($options['type'], 0, 1)); // determine size value and units label - if($bytes < 1024) { + if($bytes < 1024 || $type === 'b') { $val = $bytes; if($small) { $label = $val > 0 ? __('B', __FILE__) : ''; // bytes } else { $label = __('bytes', __FILE__); } - } else if($bytes < 1000000) { + } else if($bytes < 1000000 || $type === 'k') { $val = $bytes / 1024; $label = __('kB', __FILE__); // kilobytes - } else if($bytes < 1073741824) { + } else if($bytes < 1073741824 || $type === 'm') { $val = $bytes / 1024 / 1024; $label = __('MB', __FILE__); // megabytes } else {