summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/MY_num.php
diff options
context:
space:
mode:
authorChad Parry <github@chad.parry.org>2011-04-24 08:28:39 -0600
committerChad Parry <github@chad.parry.org>2011-04-24 08:28:39 -0600
commit26585fed03236f0f70a75959e1d3002025f4e15e (patch)
tree33a89567f40dbbdb8affcbe76baa27b242bc6d75 /modules/gallery/helpers/MY_num.php
parent809567f12850f59bdeb47a2963f6968b99b5a201 (diff)
parentc8f90e861b866d0caa86343a6c7213e923023d39 (diff)
Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto
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;
+ }
}