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

Use subdirectory media for thumbnails #31

Closed
bobobo1618 opened this issue Dec 27, 2018 · 8 comments
Closed

Use subdirectory media for thumbnails #31

bobobo1618 opened this issue Dec 27, 2018 · 8 comments
Milestone

Comments

@bobobo1618
Copy link
Contributor

I have many folders which don't themselves contain any media but contain a folder that does. E.g.

----- Top level
 +--- Folder 1
  +-- Folder 2
   +- Thing.jpg

In cases like this, I'd really like "Folder 1" to show "Thing.jpg" as a thumbnail. I tried to do this with a basic BFS in bobobo1618@8043736 but there seems to be something missing.

@bpatrik
Copy link
Owner

bpatrik commented Dec 27, 2018

Unfortunately its way more complicated.
In short:

  • you only have access to the current directory and 1-2 photos of its direct subdirectory on the client side.

Unfortunately it needs a major refactoring, maybe the best solution would be to have a dedicated 'previewPhoto' field on the directory. And one should fill this property on the server side.
It also complicates that the solution should work for both with and without database.
And the client can only render a photo if it has a valid 'parent' property.

Sorry but I don't see any simple/elegant solution right now for this problem.
I'll try to figure out a solution for this, but not sure if I'll have time for this in the next few months. :/

@bobobo1618
Copy link
Contributor Author

Fair enough, I feared that and suspected as much when I wandered around LocalStorage but I hoped I could at least use the information on the client when it was there.

I might be ambitious enough to try adding that field server-side myself, I'll see.

@bpatrik
Copy link
Owner

bpatrik commented Dec 30, 2018

I was thinking about this problem. I would not put too much effort in it. The file explorers not support this feature either. I reasonable feature around directories would be to show if a directory is empty or not.

a) I think a server side solution would be too complex compared to what gain we could get from it.
This example shows the complexity:
you have the following structure:

----- Top level
 +---- Folder 1
    +--- Folder 2
       +--- Folder 3
           +- Thing.jpg

Then you add a new photo to the folder 2 or rename thing.jpg.
Currently I don't know any nice solution to make sure that indexes in database (if the preview photo would also be stored in the db) and the local storage cache on the frontend get updated correctly.
Plus the search result folders are not showing any preview either. If a server side solution gets implemented, it would be nice if that would solve the searching problem too.

b) A semi solution could be the one that you started implementing.
The children of the current directory do not contain more directories. (Those children directories are only partial directories). You can look for the full directory in the local storage like I do in the gallery.service.ts:73.
The downside of the solution is that the cache is not super reliable. Only contains those folders that you have already opened. Plus if the cache is full, I just empty it (A more sophisticated algorithm would be nice to have, like LRU. I might do that in the future). So this solution would require a lot of string parsing on the client side and the solution would not be deterministic.

P.S.: I've merged your PR, but you were not doing the commit with your github account (?), so you are not showing up as a contributor to the project. Sorry about that.

@bobobo1618
Copy link
Contributor Author

Currently I don't know any nice solution to make sure that indexes in database

I don't know how nice it is but you can iterate up through the parents, re-calculating their previews and stop at the first parent that doesn't change. To make sure you don't do this over and over during the index, you can add all changed folders to a queue during index then deal with them at the end.

The update should also be doable with a nice fast recursive SQLite query if the database is around.

Plus if the cache is full, I just empty it (A more sophisticated algorithm would be nice to have, like LRU. I might do that in the future). So this solution would require a lot of string parsing on the client side and the solution would not be deterministic.

Hmm... With IndexedDB the cache can be made much larger, though that defers the problem rather than solves it. Still, I have 27k images in my database and it's only 3.5MB in total (the SQLite DB file), which should fit into localStorage on most browsers. IndexedDB should make this largely a non-issue though.

I've merged your PR, but you were not doing the commit with your github account (?), so you are not showing up as a contributor to the project. Sorry about that.

No worries, I noticed that when I sent the PR, it's okay.

@onlycparra
Copy link

Is there any update on this?

@bpatrik
Copy link
Owner

bpatrik commented Jan 5, 2020

Not yet. Sorry.

@garritfra
Copy link

+1 on this, my photo gallery is quite bare without previews.

@bpatrik bpatrik added this to the v1.8.5 milestone Mar 27, 2021
@bpatrik
Copy link
Owner

bpatrik commented Mar 27, 2021

PR #165 fixed this and the latest commit made some improvements to it.

bpatrik added a commit that referenced this issue Mar 28, 2021
…lecting preview that is on the same path, adding tests) #31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants