Skip to content

feat(preview): preload next and previous image - #3529

Merged
JammingBen merged 7 commits into
opencloud-eu:mainfrom
eriktews:image-preload
Oct 6, 2026
Merged

JammingBen merged 7 commits into
opencloud-eu:mainfrom
eriktews:image-preload

Conversation

@eriktews

@eriktews eriktews commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

This adds preloading to the image viewer in the web interface.

Description

The media viewer only resolved the URL of the file it was showing, so every arrow key press started a new request. Resolve the URLs of the files next to the active one as soon as it is displayed, forward first, so browsing a folder feels instant.

The loader moves into a composable so the request bookkeeping is testable on its own: one request per media file, joined instead of duplicated, aborted only when the file is neither the active one nor a neighbor. Images that don't take the preview-service path (videos, audio, vault images, SVG) are never preloaded, and public link shares additionally get their bytes pulled into the browser cache, with a fresh URL resolved once if the signed one turns out to be stale.

Screenshots would not be helpful here, but maybe a video?

Related Issue

None yet, but I can open an issue as well

How Has This Been Tested?

There were two layers of testing:

  • Unit tests were modified and added, for example packages/web-app-preview/tests/unit/composables/useMediaFileLoader.spec.ts
  • And it was tested manually against a live Opencloud 8.0.1 server with Firefox

To test it, build it and run it and open a folder with a lot of images (for example JPG) in the browser. Then scroll through them using the cursor keys and you will see that the next and previous image load almost instantly now.

The results could be more significant when testing it against a remote server. When it's tested against a server running on local host, the preloading will not be that visible.

Types of changes

  • Bugfix
  • Enhancement (a change that doesn't break existing code or deployments)
  • Breaking change (a modification that affects current functionality)
  • Technical debt (addressing code that needs refactoring or improvements)
  • Tests (adding or improving tests)
  • Documentation (updates or additions to documentation)
  • Maintenance (like dependency updates or tooling adjustments)

@eriktews

eriktews commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

I also added another change in ac80e25 that prevents trying to preload items that cannot be properly preloaded, and c06f239 contains a test for that.

Feel free to cherry pick just c06f239, 9cd4b14, and ac80e25 when you don't want the tests.

Also, the preloading is currently on the conservative side, only the next and previous images are preloaded. We could also preload the next 2-3 images. @JammingBen Do you have any opinions on that? Making that configurable and turning that into a full blown option for the user or admin settings would probably be a bit too much for this little improvement.

The media viewer only resolved the url of the file it was showing, so
every arrow key press started a new request. Resolve the urls of the
files next to the active one as soon as it is displayed, forward first,
so browsing a folder feels instant.

The loader moves into a composable so the request bookkeeping is testable
on its own: one request per media file, joined instead of duplicated,
aborted only when the file is neither the active one nor a neighbor.
Images that don't take the preview-service path (videos, audio, vault
images, svg) are never preloaded, and public link shares additionally get
their bytes pulled into the browser cache, with a fresh url resolved once
if the signed one turns out to be stale.

Along the way a file that recovers from a failed load no longer keeps
rendering the error state.
@JammingBen

Copy link
Copy Markdown
Member

Also, the preloading is currently on the conservative side, only the next and previous images are preloaded. We could also preload the next 2-3 images. @JammingBen Do you have any opinions on that? Making that configurable and turning that into a full blown option for the user or admin settings would probably be a bit too much for this little improvement.

I think preloading only the next and previous image is sufficient, let's go with that for now. I'd rather not make it configurable.

@JammingBen JammingBen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@JammingBen
JammingBen merged commit 0f1b02a into opencloud-eu:main Oct 6, 2026
31 checks passed
@openclouders openclouders mentioned this pull request Oct 6, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants