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

Custom album covers #875

Merged
merged 19 commits into from
Jan 20, 2021
Merged

Custom album covers #875

merged 19 commits into from
Jan 20, 2021

Conversation

evoludolab
Copy link
Contributor

@evoludolab evoludolab commented Jan 18, 2021

Draft pull request to implement setting custom cover images for albums, see #442

This pull request implements the back end for setting custom album covers. The corresponding pull request for the front end extends the context menu for photos and albums with Set/Remove Album cover to set/remove custom album covers of the parent album, see LycheeOrg/Lychee-front#239

  • add a cover_id column and cover relationship to Album
  • thumb is now added in the toReturnArray() function which simplifies the code at multiple places
  • the cover image is greedy fetched to lower the number of SQL queries.

Future work (for another PR):

  • allow the selection of the ancestor for which the photo is to be set, for now this is only for the direct parent.
  • allow the ability to clear the cover photo without having to click on a picture.

IMPORTANT:

  • ⚠️ this draft uses album.description to store the information of custom covers. It requires a new column cover in the album table, which is beyond my pay grade.
  • SQL query in AlbumController.php should be reviewed (this is completely unfamiliar territory...)
  • something seems amiss with the gulpfile because iconic.svg does not get processed (the new icon needs to be manually added to resources/views/includes/svg.blade.php and resources/views/view.blade.php)
  • only English localization done
  • support for 3 distinct images for albums dropped (seems overkill given that 2 are barely visible); if this is acceptable some code cleaning and streamlining would be recommended

implement custom album covers

IMPORTANT: this is abusing album.description to store id of cover photo (needs to be changed once album table includes column for covers)

IMPORTANT: something seems amiss with the gulpfile because iconic.svg does not get processed (the new icon needs to be manually added to resources/views/includes/svg.blade.php and resources/views/view.blade.php)

IMPORTANT: support for 3 distinct images for albums dropped (overkill given that 2 are barely visible)
keep track of photoID of current cover of albums. facilitates setting custom album covers of the parent.
@ildyria
Copy link
Member

ildyria commented Jan 18, 2021

Still WIP. Incoming changes. Please wait for #873 to be merged.

@ildyria
Copy link
Member

ildyria commented Jan 18, 2021

@evoludolab please check.

@ildyria ildyria requested a review from kamil4 January 18, 2021 15:58
Copy link
Contributor

@kamil4 kamil4 left a comment

Choose a reason for hiding this comment

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

Looks good overall.

I still need to look at the front end, and I'd like to try it out...

app/Http/Controllers/AlbumController.php Outdated Show resolved Hide resolved
app/Http/Controllers/SearchController.php Outdated Show resolved Hide resolved
app/Models/Album.php Outdated Show resolved Hide resolved
app/Models/Extensions/AlbumGetters.php Show resolved Hide resolved
app/Models/Extensions/AlbumGetters.php Show resolved Hide resolved
@evoludolab
Copy link
Contributor Author

Wow this is cool! Unfortunately I have a day job and won't have time to check until later ☹️ The first impression is great and everything seems to work! The badge is nice but a tad intrusive - especially on sub albums. Maybe a tooltip would help to explain that this marks the cover image of the parent? Anyways, I'll test more thoroughly later. Thanks!

@kamil4
Copy link
Contributor

kamil4 commented Jan 18, 2021

The badge is nice but a tad intrusive - especially on sub albums.

That's why I tweaked it to be the rightmost one... As to it being intrusive, we use badges all over the place already, so adding one more doesn't seem like a big stretch...

Maybe a tooltip would help to explain that this marks the cover image of the parent?

We don't currently have tooltips in that area of the UI -- I think we may be using them only in the menu bar? I suppose we could add some but I'm not sure how necessary it is in this case, as the badge appears immediately after the user sets a cover, so it should be pretty obvious what it indicates. Of course, after a while one might forget...

@kamil4
Copy link
Contributor

kamil4 commented Jan 18, 2021

I'm wondering about the security implications here. Shouldn't we at least be checking that the new cover Photo belongs to the user? I think the upload middleware would automagically do it if the request field was called photoID, not the current cover_id...

@ildyria
Copy link
Member

ildyria commented Jan 18, 2021

I'm wondering about the security implications here. Shouldn't we at least be checking that the new cover Photo belongs to the user? I think the upload middleware would automatically do it if the request field was called photoID, not the current cover_id...

Then we just need to update the Ajax query to send a photoId :)

@kamil4
Copy link
Contributor

kamil4 commented Jan 18, 2021

Done...

@evoludolab
Copy link
Contributor Author

@kamil4 nothing against badges and I am clearly in favour of marking the cover - makes everything more transparent! What about adding a more discreet marker similar to albums that contain sub albums?

Concerning tooltips I was more thinking of visitors that wonder what the orange badge means. But that seems quite cosmetic and probably better suited for a separate discussion.

@ildyria
Copy link
Member

ildyria commented Jan 18, 2021

Concerning tooltips I was more thinking of visitors that wonder what the orange badge means. But that seems quite cosmetic and probably better suited for a separate discussion.

Visitors do not see badges.

@evoludolab
Copy link
Contributor Author

evoludolab commented Jan 18, 2021

Visitors do not see badges.

@ildyria Oh, did not yet notice... In that case long live the orange badge!

@evoludolab
Copy link
Contributor Author

As far as I can tell everything works like a charm. I am looking forward to studying all your changes and improvements carefully to get a better understanding of Lychee. It's been a pleasure - thanks!

@sonarcloud
Copy link

sonarcloud bot commented Jan 20, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@ildyria ildyria merged commit c7bbd53 into LycheeOrg:master Jan 20, 2021
@evoludolab evoludolab deleted the custom-covers branch January 30, 2021 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants