aboutsummaryrefslogtreecommitdiff
path: root/models/image.go
diff options
context:
space:
mode:
authorBobby <[email protected]>2025-07-07 22:57:31 +0530
committerBobby <[email protected]>2025-07-07 22:57:31 +0530
commit52a0248c1c81a14699b3d33ba7efe0c56bbe7477 (patch)
tree02d35fee769d518beb5dd01715e84d13ea421d51 /models/image.go
parentb6a04140f2668a0dcae4befcd272e05b75bd14e5 (diff)
downloadimageboard-52a0248c1c81a14699b3d33ba7efe0c56bbe7477.tar.xz
imageboard-52a0248c1c81a14699b3d33ba7efe0c56bbe7477.zip
massive y2k retro overhaul with sidebar, context processors, and proper database organization
Diffstat (limited to 'models/image.go')
-rw-r--r--models/image.go13
1 files changed, 2 insertions, 11 deletions
diff --git a/models/image.go b/models/image.go
index fef3bf8..03d4c38 100644
--- a/models/image.go
+++ b/models/image.go
@@ -3,6 +3,7 @@ package models
import (
"fmt"
"imageboard/config"
+ "imageboard/utils/format"
"imageboard/utils/math"
"strings"
@@ -50,17 +51,7 @@ func (s *ImageSize) GetDimensions() string {
}
func (s *ImageSize) GetFileSizeFormatted() string {
- const unit = 1024
- if s.FileSize < unit {
- return fmt.Sprintf("%d B", s.FileSize)
- }
- div, exp := int64(unit), 0
- for n := s.FileSize / unit; n >= unit; n /= unit {
- div *= unit
- exp++
- }
-
- return fmt.Sprintf("%.2f %sB", float64(s.FileSize)/float64(div), "KMGTPE"[exp:exp+1])
+ return format.FileSize(s.FileSize)
}
type Image struct {