Size units…
-
Hi,
I’m using your nice piece of software. Thanks for that.
However, I’m trying to change the way it presents the file sizes.
Your current ‘borrowed’ code:
{
$sz = ‘BKMGTP’;
$factor = floor((strlen($bytes) – 1) / 3);
return sprintf(“%.{$decimals}f”, $bytes / pow(1024, $factor)) . @$sz[$factor];
}shows for example: (45M), (21K), etc. This was not natural/automatic to read for us (university research group).
I mean, according to the International System I’m using, it’s not ok to show ‘’BKMGTP’’ instead of ‘BytesKbMbGbTbPb, and after the number, there should be a space and then the measure unit:
For example:
(12.54 Mb)
(5 Gb)
(23 Kb)
Etc.It could be a silly thing, but we’d like to have it like I describe.
I’m not a PHP programmer, and thus I was not able to change your borrowed code, but I found (in the same page where you borrowed yours) a larger piece of code belonging to a Russian-like named guy (sorry for stereotyping him):
{
$bytes = floatval($bytes);
$arBytes = array(
0 => array(
“UNIT” => ” Tb”,
“VALUE” => pow(1024, 4)
),
1 => array(
“UNIT” => ” Gb”,
“VALUE” => pow(1024, 3)
),
2 => array(
“UNIT” => ” Mb”,
“VALUE” => pow(1024, 2)
),
3 => array(
“UNIT” => ” Kb”,
“VALUE” => 1024
),
4 => array(
“UNIT” => ” Bytes”,
“VALUE” => 1
),
);foreach($arBytes as $arItem)
{
if($bytes >= $arItem[“VALUE”])
{
$result = $bytes / $arItem[“VALUE”];
$result = str_replace(“.”, “,” , strval(round($result, $decimals))).” “.$arItem[“UNIT”];
break;
}
}
return $result;
}The thing is, your plugin seems to reset itself, trashing my inserted code.
That’s certainly good for your code but not for my humble intentions… ??
Could you please do something about the units?
One more extra thing. Could you please add a way to target the links to pop-up windows?
Thanks a lot for your help and understanding.
Best regards,
Fernando.
- The topic ‘Size units…’ is closed to new replies.