Use random performer image if none provided
19
pkg/api/images.go
Normal 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])
|
||||
}
|
||||
|
|
@ -19,10 +19,11 @@ func (r *mutationResolver) PerformerCreate(ctx context.Context, input models.Per
|
|||
var err error
|
||||
|
||||
if input.Image == nil {
|
||||
input.Image = &models.DefaultPerformerImage
|
||||
imageData, err = getRandomPerformerImage()
|
||||
} else {
|
||||
_, imageData, err = utils.ProcessBase64Image(*input.Image)
|
||||
}
|
||||
|
||||
_, imageData, err = utils.ProcessBase64Image(*input.Image)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ func Start() {
|
|||
//legacyUiBox = packr.New("UI Box", "../../ui/v1/dist/stash-frontend")
|
||||
setupUIBox = packr.New("Setup UI Box", "../../ui/setup")
|
||||
|
||||
initialiseImages()
|
||||
|
||||
r := chi.NewRouter()
|
||||
|
||||
r.Use(middleware.Recoverer)
|
||||
|
|
|
|||
|
|
@ -27,5 +27,3 @@ type Performer struct {
|
|||
CreatedAt SQLiteTimestamp `db:"created_at" json:"created_at"`
|
||||
UpdatedAt SQLiteTimestamp `db:"updated_at" json:"updated_at"`
|
||||
}
|
||||
|
||||
var DefaultPerformerImage string = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAACYktHRAD/h4/MvwAAB/hJREFUeF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rcJHS8/nxLFhD1i6bzIJUQjBGHIopLXEwbSzFdXcKbpKvaNJKuxlMxFwaAXm27csSCVIJ4lDR82BxR+LWMHO2sUka8hpBvMBVSdZmcLHJ3kcE0HK1aoJUQwGEMDzzyJpCY/IbGxvxO134wsusswS4Hm46D5ebT50JUg1pZaU4uAwejWoQgmFy0JgWFGaNag5cDzc/eSQiSDv+0+JNkHrgPhAGkZhKqW6f0RSllhjcdP5+IoCkkVyD3AWpBGvBt1dbDTutcF+2N4vAjZuqXnhi1JPVIUQoBCUIYCmvXr26tYDFjAHnmGQNnrhIxKiOYYhB4pD177kmOEEAF4Yo1ZZCECW3Z6Nos1oFQZkSqbXuwu8ihnQfuguCFAS4ofW+IxBhyPepfsl4EnH4HeohFtNwT7WmQ7AIdv+G5KYqCVYQ4IYSiLWm6LEuzunNO3A3ImhBEqhnmOLIWsskYA1sw6aAC51CCAJYC8UcC0lpO8tJBDi0hjO0XFX92hRGkErInIgRxBesJpmmIXNCBKpoYkxoGVQaCilIKxNGh0HJf5SCBEYpSFAY8zcMQ9XFKHJwbwAAAABJRU5ErkJggg=="
|
||||
|
|
|
|||
BIN
static/performer/NoName01.png
Normal file
|
After Width: | Height: | Size: 155 KiB |
BIN
static/performer/NoName02.png
Normal file
|
After Width: | Height: | Size: 146 KiB |
BIN
static/performer/NoName03.png
Normal file
|
After Width: | Height: | Size: 157 KiB |
BIN
static/performer/NoName04.png
Normal file
|
After Width: | Height: | Size: 155 KiB |
BIN
static/performer/NoName05.png
Normal file
|
After Width: | Height: | Size: 149 KiB |
BIN
static/performer/NoName06.png
Normal file
|
After Width: | Height: | Size: 153 KiB |
BIN
static/performer/NoName07.png
Normal file
|
After Width: | Height: | Size: 153 KiB |
BIN
static/performer/NoName08.png
Normal file
|
After Width: | Height: | Size: 158 KiB |
BIN
static/performer/NoName09.png
Normal file
|
After Width: | Height: | Size: 152 KiB |
BIN
static/performer/NoName10.png
Normal file
|
After Width: | Height: | Size: 159 KiB |
BIN
static/performer/NoName11.png
Normal file
|
After Width: | Height: | Size: 150 KiB |
BIN
static/performer/NoName12.png
Normal file
|
After Width: | Height: | Size: 152 KiB |
BIN
static/performer/NoName13.png
Normal file
|
After Width: | Height: | Size: 136 KiB |
BIN
static/performer/NoName14.png
Normal file
|
After Width: | Height: | Size: 142 KiB |
BIN
static/performer/NoName15.png
Normal file
|
After Width: | Height: | Size: 158 KiB |
BIN
static/performer/NoName16.png
Normal file
|
After Width: | Height: | Size: 167 KiB |
BIN
static/performer/NoName17.png
Normal file
|
After Width: | Height: | Size: 149 KiB |
BIN
static/performer/NoName18.png
Normal file
|
After Width: | Height: | Size: 154 KiB |
BIN
static/performer/NoName19.png
Normal file
|
After Width: | Height: | Size: 159 KiB |
BIN
static/performer/NoName20.png
Normal file
|
After Width: | Height: | Size: 158 KiB |
BIN
static/performer/NoName21.png
Normal file
|
After Width: | Height: | Size: 145 KiB |
BIN
static/performer/NoName22.png
Normal file
|
After Width: | Height: | Size: 150 KiB |
BIN
static/performer/NoName23.png
Normal file
|
After Width: | Height: | Size: 151 KiB |
BIN
static/performer/NoName24.png
Normal file
|
After Width: | Height: | Size: 162 KiB |
BIN
static/performer/NoName25.png
Normal file
|
After Width: | Height: | Size: 150 KiB |
BIN
static/performer/NoName26.png
Normal file
|
After Width: | Height: | Size: 150 KiB |
BIN
static/performer/NoName27.png
Normal file
|
After Width: | Height: | Size: 152 KiB |
BIN
static/performer/NoName28.png
Normal file
|
After Width: | Height: | Size: 158 KiB |
BIN
static/performer/NoName29.png
Normal file
|
After Width: | Height: | Size: 157 KiB |
BIN
static/performer/NoName30.png
Normal file
|
After Width: | Height: | Size: 153 KiB |
BIN
static/performer/NoName31.png
Normal file
|
After Width: | Height: | Size: 148 KiB |
BIN
static/performer/NoName32.png
Normal file
|
After Width: | Height: | Size: 157 KiB |
BIN
static/performer/NoName33.png
Normal file
|
After Width: | Height: | Size: 154 KiB |
BIN
static/performer/NoName34.png
Normal file
|
After Width: | Height: | Size: 151 KiB |
BIN
static/performer/NoName35.png
Normal file
|
After Width: | Height: | Size: 151 KiB |
BIN
static/performer/NoName36.png
Normal file
|
After Width: | Height: | Size: 150 KiB |
BIN
static/performer/NoName37.png
Normal file
|
After Width: | Height: | Size: 146 KiB |
BIN
static/performer/NoName38.png
Normal file
|
After Width: | Height: | Size: 136 KiB |
BIN
static/performer/NoName39.png
Normal file
|
After Width: | Height: | Size: 150 KiB |
BIN
static/performer/NoName40.png
Normal file
|
After Width: | Height: | Size: 164 KiB |