aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/files-cache/avatar-permanent-file-cache.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-06-06 15:59:51 +0200
committerChocobozzz <me@florianbigard.com>2023-06-29 10:19:33 +0200
commitf162d32da098aa55f6de2367142faa166edb7c08 (patch)
tree31c6a96972994171853cb6c4e0b88b63241f8979 /server/lib/files-cache/avatar-permanent-file-cache.ts
parenta673d9e848e51186602548a621e05925663b98be (diff)
downloadPeerTube-f162d32da098aa55f6de2367142faa166edb7c08.tar.gz
PeerTube-f162d32da098aa55f6de2367142faa166edb7c08.tar.zst
PeerTube-f162d32da098aa55f6de2367142faa166edb7c08.zip
Support lazy download thumbnails
Diffstat (limited to 'server/lib/files-cache/avatar-permanent-file-cache.ts')
-rw-r--r--server/lib/files-cache/avatar-permanent-file-cache.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/server/lib/files-cache/avatar-permanent-file-cache.ts b/server/lib/files-cache/avatar-permanent-file-cache.ts
new file mode 100644
index 000000000..89228c5a5
--- /dev/null
+++ b/server/lib/files-cache/avatar-permanent-file-cache.ts
@@ -0,0 +1,27 @@
1import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants'
2import { ActorImageModel } from '@server/models/actor/actor-image'
3import { MActorImage } from '@server/types/models'
4import { AbstractPermanentFileCache } from './shared'
5import { CONFIG } from '@server/initializers/config'
6
7export class AvatarPermanentFileCache extends AbstractPermanentFileCache<ActorImageModel> {
8
9 constructor () {
10 super(CONFIG.STORAGE.ACTOR_IMAGES)
11 }
12
13 protected loadModel (filename: string) {
14 return ActorImageModel.loadByName(filename)
15 }
16
17 protected getImageSize (image: MActorImage): { width: number, height: number } {
18 if (image.width && image.height) {
19 return {
20 height: image.height,
21 width: image.width
22 }
23 }
24
25 return ACTOR_IMAGES_SIZE[image.type][0]
26 }
27}