mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
feat(web): use thumbhash as a cache key (#16106)
Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
parent
c524fcf084
commit
f386b4d377
8 changed files with 41 additions and 38 deletions
|
|
@ -70,19 +70,19 @@
|
|||
for (const preloadAsset of preloadAssets || []) {
|
||||
if (preloadAsset.type === AssetTypeEnum.Image) {
|
||||
let img = new Image();
|
||||
img.src = getAssetUrl(preloadAsset.id, useOriginal, preloadAsset.checksum);
|
||||
img.src = getAssetUrl(preloadAsset.id, useOriginal, preloadAsset.thumbhash);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const getAssetUrl = (id: string, useOriginal: boolean, checksum: string) => {
|
||||
const getAssetUrl = (id: string, useOriginal: boolean, cacheKey: string | null) => {
|
||||
if (sharedLink && (!sharedLink.allowDownload || !sharedLink.showMetadata)) {
|
||||
return getAssetThumbnailUrl({ id, size: AssetMediaSize.Preview, checksum });
|
||||
return getAssetThumbnailUrl({ id, size: AssetMediaSize.Preview, cacheKey });
|
||||
}
|
||||
|
||||
return useOriginal
|
||||
? getAssetOriginalUrl({ id, checksum })
|
||||
: getAssetThumbnailUrl({ id, size: AssetMediaSize.Preview, checksum });
|
||||
? getAssetOriginalUrl({ id, cacheKey })
|
||||
: getAssetThumbnailUrl({ id, size: AssetMediaSize.Preview, cacheKey });
|
||||
};
|
||||
|
||||
copyImage = async () => {
|
||||
|
|
@ -158,7 +158,7 @@
|
|||
preload(useOriginalImage, preloadAssets);
|
||||
});
|
||||
|
||||
let imageLoaderUrl = $derived(getAssetUrl(asset.id, useOriginalImage, asset.checksum));
|
||||
let imageLoaderUrl = $derived(getAssetUrl(asset.id, useOriginalImage, asset.thumbhash));
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue