diff options
author | jan <jan@ruken.pw> | 2015-12-29 19:05:45 (UTC) |
---|---|---|
committer | jan <jan@ruken.pw> | 2015-12-29 19:05:45 (UTC) |
commit | 5a87c787713edb20b735b8460f5ab49d0041e236 (patch) | |
tree | 1be2c03f4f830db580b6cd9c785990362da4ea57 /modules | |
parent | d6d002dda847b9bdeb6f464f7a1fafaab0419a55 (diff) |
thumbnail kann jetzt bei gril.ImagePath bevorzugt werden. das bild des grils sollte jetzt auch nicht mehr gequetscht aussehen.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/grils/gril.go | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/modules/grils/gril.go b/modules/grils/gril.go index a450647..fe316cd 100644 --- a/modules/grils/gril.go +++ b/modules/grils/gril.go | |||
@@ -28,23 +28,26 @@ type Gril struct { | |||
28 | Lists []int | 28 | Lists []int |
29 | } | 29 | } |
30 | 30 | ||
31 | func (g *Gril) ImagePath() string { | 31 | func (g *Gril) ImagePath(prioritizeThumbnail bool) string { |
32 | var big string | ||
32 | exts := []string{"png", "jpg", "gif", "jpeg"} | 33 | exts := []string{"png", "jpg", "gif", "jpeg"} |
33 | var imagePath string | ||
34 | for _, ext := range exts { | 34 | for _, ext := range exts { |
35 | path := fmt.Sprintf("assets/img/gril/%d/0.%s", g.ID, ext) | 35 | path := fmt.Sprintf("assets/img/gril/%d/0.%s", g.ID, ext) |
36 | if _, err := os.Stat(path); err == nil { | 36 | if _, err := os.Stat(path); err == nil { |
37 | return path | 37 | if prioritizeThumbnail { |
38 | big = path | ||
39 | } else { | ||
40 | return path | ||
41 | } | ||
38 | } | 42 | } |
39 | } | 43 | } |
40 | 44 | ||
41 | if len(imagePath) == 0 { | 45 | for _, ext := range exts { |
42 | for _, ext := range exts { | 46 | path := fmt.Sprintf("assets/img/gril/%d/1.%s", g.ID, ext) |
43 | path := fmt.Sprintf("assets/img/gril/%d/1.%s", g.ID, ext) | 47 | if _, err := os.Stat(path); err == nil { |
44 | if _, err := os.Stat(path); err == nil { | 48 | return path |
45 | return path | ||
46 | } | ||
47 | } | 49 | } |
48 | } | 50 | } |
49 | return "" | 51 | |
52 | return big | ||
50 | } | 53 | } |