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])
}

View file

@ -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
}

View file

@ -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)

View file

@ -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/hJREFUeF7tnVdz2zgURmEnjpO4p7rX9Jf8xf2LyUPcex/3OD2xvXu45K5GViFxL0BQ4pnRSPKMbZEfbgMuoA5jzM0/j5JA6IyfSwKhFCQwSkECI9gYcu/ePdPT02O6u7ujB+95dHR0mLt370bPnZ2d5vr62lxdXZmfP3+aHz9+mK9fv5ovX75Er4tIMIJ0dXWZwcFB09/fHwnBew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SDv+0+JNkHrgPhAGkZhKqW6f0RSllhjcdP5+IoCkkVyD3AWpBGvBt1dbDTutcF+2N4vAjZuqXnhi1JPVIUQoBCUIYCmvXr26tYDFjAHnmGQNnrhIxKiOYYhB4pD177kmOEEAF4Yo1ZZCECW3Z6Nos1oFQZkSqbXuwu8ihnQfuguCFAS4ofW+IxBhyPepfsl4EnH4HeohFtNwT7WmQ7AIdv+G5KYqCVYQ4IYSiLWm6LEuzunNO3A3ImhBEqhnmOLIWsskYA1sw6aAC51CCAJYC8UcC0lpO8tJBDi0hjO0XFX92hRGkErInIgRxBesJpmmIXNCBKpoYkxoGVQaCilIKxNGh0HJf5SCBEYpSFAY8zcMQ9XFKHJwbwAAAABJRU5ErkJggg=="

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB