mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 14:05:56 +02:00
BUG Fix file size format in document links
This commit is contained in:
parent
79c8efee74
commit
7ba2a4617a
@ -661,15 +661,11 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
|
|||||||
return filesize($this->getFullPath());
|
return filesize($this->getFullPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An alias to DMSDocument::getSize()
|
||||||
|
*/
|
||||||
function getFileSizeFormatted(){
|
function getFileSizeFormatted(){
|
||||||
if($size = $this->getSize()){
|
return $this->getSize();
|
||||||
if($size < 1024) return $size . ' bytes';
|
|
||||||
if($size < 1024*10) return (round($size/1024*10)/10). ' KB';
|
|
||||||
if($size < 1024*1024) return round($size/1024) . ' KB';
|
|
||||||
if($size < 1024*1024*10) return (round(($size/1024)/1024*10)/10) . ' MB';
|
|
||||||
if($size < 1024*1024*1024) return round(($size/1024)/1024) . ' MB';
|
|
||||||
return round($size/(1024*1024*1024)*10)/10 . ' GB';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user