summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/MY_num.php
diff options
context:
space:
mode:
authorChad Kieffer <ckieffer@gmail.com>2011-04-23 15:02:29 -0400
committerChad Kieffer <ckieffer@gmail.com>2011-04-23 15:02:29 -0400
commit268f9425d918d14e1839b3e22203a8869093f3f0 (patch)
tree3a0676e1fa0b158262e9ae8f0faef0474998b061 /modules/gallery/helpers/MY_num.php
parent07f654c8d9918608c8229404585874ce5aba7ab2 (diff)
parenta9eb995dd2b64667c300c6193656b6cdfeb4e2a5 (diff)
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/gallery/helpers/MY_num.php')
-rw-r--r--modules/gallery/helpers/MY_num.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/gallery/helpers/MY_num.php b/modules/gallery/helpers/MY_num.php
index 9787044c..842a2ee3 100644
--- a/modules/gallery/helpers/MY_num.php
+++ b/modules/gallery/helpers/MY_num.php
@@ -37,4 +37,18 @@ class num extends num_Core {
return $val;
}
+
+ /**
+ * Convert a size value as accepted by PHP's shorthand to bytes.
+ * ref: http://us2.php.net/manual/en/function.ini-get.php
+ * ref: http://us2.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
+ */
+ static function convert_to_human_readable($num) {
+ foreach (array("G" => 1e9, "M" => 1e6, "K" => 1e3) as $k => $v) {
+ if ($num > $v) {
+ $num = round($num / $v) . $k;
+ }
+ }
+ return $num;
+ }
}