Use random performer image if none provided

This commit is contained in:
WithoutPants
2019-08-24 17:17:25 +10:00
parent 20662532d8
commit 9c92e64106
44 changed files with 24 additions and 4 deletions

19
pkg/api/images.go Normal file
View File

@@ -0,0 +1,19 @@
package api
import (
"math/rand"
"github.com/gobuffalo/packr/v2"
)
var performerBox *packr.Box
func initialiseImages() {
performerBox = packr.New("Performer Box", "../../static/performer")
}
func getRandomPerformerImage() ([]byte, error) {
imageFiles := performerBox.List()
index := rand.Intn(len(imageFiles))
return performerBox.Find(imageFiles[index])
}