Added "size" method.
This commit is contained in:
parent
4229c8ff8b
commit
a566656055
1 changed files with 25 additions and 0 deletions
|
|
@ -46,6 +46,7 @@ use WebGUI::Utility;
|
|||
$attachment->getFilename;
|
||||
$attachment->getIcon;
|
||||
$attachment->getPath;
|
||||
$attachment->getSize;
|
||||
$attachment->getThumbnail;
|
||||
$attachment->getType;
|
||||
$attachment->getURL;
|
||||
|
|
@ -226,6 +227,30 @@ sub getPath {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getSize ( )
|
||||
|
||||
Returns the size of this file.
|
||||
|
||||
=cut
|
||||
|
||||
sub getSize {
|
||||
my ($size);
|
||||
my (@attributes) = stat($_[0]->{_node}->getPath.'/'.$_[0]->getFilename);
|
||||
if ($attributes[7] > 1048576) {
|
||||
$size = round($attributes[7]/1048576);
|
||||
$size .= 'mb';
|
||||
} elsif ($attributes[7] > 1024) {
|
||||
$size = round($attributes[7]/1024);
|
||||
$size .= 'kb';
|
||||
} else {
|
||||
$size = $attributes[7]."b";
|
||||
}
|
||||
return $size;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getThumbnail ( )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue