mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Show studio as text in scene cards where studio image isn't set (#965)
This commit is contained in:
@@ -24,6 +24,19 @@ func (r *studioResolver) URL(ctx context.Context, obj *models.Studio) (*string,
|
|||||||
func (r *studioResolver) ImagePath(ctx context.Context, obj *models.Studio) (*string, error) {
|
func (r *studioResolver) ImagePath(ctx context.Context, obj *models.Studio) (*string, error) {
|
||||||
baseURL, _ := ctx.Value(BaseURLCtxKey).(string)
|
baseURL, _ := ctx.Value(BaseURLCtxKey).(string)
|
||||||
imagePath := urlbuilders.NewStudioURLBuilder(baseURL, obj.ID).GetStudioImageURL()
|
imagePath := urlbuilders.NewStudioURLBuilder(baseURL, obj.ID).GetStudioImageURL()
|
||||||
|
|
||||||
|
qb := models.NewStudioQueryBuilder()
|
||||||
|
hasImage, err := qb.HasStudioImage(obj.ID)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// indicate that image is missing by setting default query param to true
|
||||||
|
if !hasImage {
|
||||||
|
imagePath = imagePath + "?default=true"
|
||||||
|
}
|
||||||
|
|
||||||
return &imagePath, nil
|
return &imagePath, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,10 +26,14 @@ func (rs studioRoutes) Routes() chi.Router {
|
|||||||
func (rs studioRoutes) Image(w http.ResponseWriter, r *http.Request) {
|
func (rs studioRoutes) Image(w http.ResponseWriter, r *http.Request) {
|
||||||
studio := r.Context().Value(studioKey).(*models.Studio)
|
studio := r.Context().Value(studioKey).(*models.Studio)
|
||||||
qb := models.NewStudioQueryBuilder()
|
qb := models.NewStudioQueryBuilder()
|
||||||
image, _ := qb.GetStudioImage(studio.ID, nil)
|
var image []byte
|
||||||
|
|
||||||
defaultParam := r.URL.Query().Get("default")
|
defaultParam := r.URL.Query().Get("default")
|
||||||
if len(image) == 0 || defaultParam == "true" {
|
|
||||||
|
if defaultParam != "true" {
|
||||||
|
image, _ = qb.GetStudioImage(studio.ID, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(image) == 0 {
|
||||||
_, image, _ = utils.ProcessBase64Image(models.DefaultStudioImage)
|
_, image, _ = utils.ProcessBase64Image(models.DefaultStudioImage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -296,3 +296,12 @@ func (qb *StudioQueryBuilder) GetStudioImage(studioID int, tx *sqlx.Tx) ([]byte,
|
|||||||
query := `SELECT image from studios_image WHERE studio_id = ?`
|
query := `SELECT image from studios_image WHERE studio_id = ?`
|
||||||
return getImage(tx, query, studioID)
|
return getImage(tx, query, studioID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (qb *StudioQueryBuilder) HasStudioImage(studioID int) (bool, error) {
|
||||||
|
ret, err := runCountQuery(buildCountQuery("SELECT studio_id from studios_image WHERE studio_id = ?"), []interface{}{studioID})
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret == 1, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
### 🎨 Improvements
|
### 🎨 Improvements
|
||||||
|
* Show scene studio as text where image is missing.
|
||||||
* Use natural sort for titles and movie names.
|
* Use natural sort for titles and movie names.
|
||||||
* Support optional preview and sprite generation during scanning.
|
* Support optional preview and sprite generation during scanning.
|
||||||
* Support configurable number of threads for scanning and generation.
|
* Support configurable number of threads for scanning and generation.
|
||||||
|
|||||||
@@ -69,8 +69,14 @@ export const SceneCard: React.FC<ISceneCardProps> = (
|
|||||||
props: ISceneCardProps
|
props: ISceneCardProps
|
||||||
) => {
|
) => {
|
||||||
const config = useConfiguration();
|
const config = useConfiguration();
|
||||||
|
|
||||||
|
// studio image is missing if it uses the default
|
||||||
|
const missingStudioImage = props.scene.studio?.image_path?.endsWith(
|
||||||
|
"?default=true"
|
||||||
|
);
|
||||||
const showStudioAsText =
|
const showStudioAsText =
|
||||||
config?.data?.configuration.interface.showStudioAsText ?? false;
|
missingStudioImage ||
|
||||||
|
(config?.data?.configuration.interface.showStudioAsText ?? false);
|
||||||
|
|
||||||
function maybeRenderRatingBanner() {
|
function maybeRenderRatingBanner() {
|
||||||
if (!props.scene.rating) {
|
if (!props.scene.rating) {
|
||||||
|
|||||||
Reference in New Issue
Block a user