mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00
Support lazy download thumbnails
This commit is contained in:
parent
a673d9e848
commit
f162d32da0
27 changed files with 272 additions and 212 deletions
27
server/lib/files-cache/avatar-permanent-file-cache.ts
Normal file
27
server/lib/files-cache/avatar-permanent-file-cache.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants'
|
||||
import { ActorImageModel } from '@server/models/actor/actor-image'
|
||||
import { MActorImage } from '@server/types/models'
|
||||
import { AbstractPermanentFileCache } from './shared'
|
||||
import { CONFIG } from '@server/initializers/config'
|
||||
|
||||
export class AvatarPermanentFileCache extends AbstractPermanentFileCache<ActorImageModel> {
|
||||
|
||||
constructor () {
|
||||
super(CONFIG.STORAGE.ACTOR_IMAGES)
|
||||
}
|
||||
|
||||
protected loadModel (filename: string) {
|
||||
return ActorImageModel.loadByName(filename)
|
||||
}
|
||||
|
||||
protected getImageSize (image: MActorImage): { width: number, height: number } {
|
||||
if (image.width && image.height) {
|
||||
return {
|
||||
height: image.height,
|
||||
width: image.width
|
||||
}
|
||||
}
|
||||
|
||||
return ACTOR_IMAGES_SIZE[image.type][0]
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue