Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for assigning any image from a gallery as the cover #5053

Merged
merged 6 commits into from
Aug 29, 2024

Conversation

sezzim
Copy link
Contributor

@sezzim sezzim commented Jul 6, 2024

Adds support for assigning any image from a gallery as the cover.

This stores the cover assignment in a new boolean column in the galleries_images table. The benefit of this is it ensures the selected image belongs to the gallery without new foreign key constraints. The obvious alternative would be to store the cover assignment in a cover_image_id column in the galleries table.

I believe this would resolve #1432 and #4879.

A couple possible refinements that aren't implemented:

  • The "restore default cover" action could be shown conditionally, only when a custom cover assignment exists. This would require an additional change to the API data model.
  • Finding the cover image could be consolidated into fewer database queries (although it might require non-standard query functions). I believe the additional cost to look for a custom cover assignment is small, because it only needs to look at contiguous records in the galleries_images table (not the files and folder tables). The bigger performance savings would actually be from combining the two queries that look for a cover by regex or by path.

Resolves #1432
Resolves #4879

@WithoutPants WithoutPants added the feature Pull requests that add a new feature label Aug 29, 2024
@WithoutPants WithoutPants added this to the Version 0.27.0 milestone Aug 29, 2024
Copy link
Collaborator

@WithoutPants WithoutPants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this valuable and well-crafted feature, and apologies for taking so long to review it.

I found no major issues with this, and made the following minor changes:

  • changed the wording of the cover setting label to Set as Cover as I felt it was more succinct
  • moved the Restore Default Cover menu item from the query menu to the main gallery overflow menu on the left, as I felt this was a more appropriate place for it.
  • adjusted the query when resetting the cover to only update where cover = true so that it hit fewer rows
  • added a unique index on gallery_id and cover in galleries_images - this serves to prevent multiple images being set as cover for a gallery, and optimises cover queries on larger galleries

This work sets us up for future work to automatically set the cover during scan so we can do away with having to search for cover.jpg image on every cover request.

@WithoutPants WithoutPants merged commit 68738bd into stashapp:develop Aug 29, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Pull requests that add a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] GQL mutation to set gallery cover [Feature] Gallery custom thumbnail cover
2 participants