Skip to content

Commit 3829db3

Browse files
author
Carl Schwan
committed
feat: Read previews information from new DAV endpoint
Signed-off-by: Carl Schwan <[email protected]>
1 parent 9030a09 commit 3829db3

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

apps/files/src/components/FileEntry/FileEntryPreview.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<script lang="ts">
5353
import type { Node } from '@nextcloud/files'
5454
import type { PropType } from 'vue'
55-
import type { UserConfig } from '../../types.ts'
55+
import type { UserConfig, PreviewMetadata } from '../../types.ts'
5656
5757
import { FileType } from '@nextcloud/files'
5858
import { translate as t } from '@nextcloud/l10n'
@@ -164,6 +164,14 @@ export default defineComponent({
164164
return url.href
165165
}
166166
167+
if (this.source.attributes['preview-metadata']) {
168+
let metadata: PreviewMetadata[] = JSON.parse(this.source.attributes['preview-metadata'])
169+
metadata = metadata.filter((preview) => preview.height <= 256 && this.cropPreviews === preview.cropped && preview.preview_url)
170+
if (metadata.length > 0) {
171+
return metadata[0]?.preview_url;
172+
}
173+
}
174+
167175
try {
168176
const previewUrl = this.source.attributes.previewUrl
169177
|| (this.isPublic

apps/files/src/init.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,8 @@ registerPreviewServiceWorker()
7575
registerDavProperty('nc:hidden', { nc: 'http://nextcloud.org/ns' })
7676
registerDavProperty('nc:is-mount-root', { nc: 'http://nextcloud.org/ns' })
7777
registerDavProperty('nc:metadata-blurhash', { nc: 'http://nextcloud.org/ns' })
78+
registerDavProperty('nc:preview-metadata', { nc: 'http://nextcloud.org/ns' })
79+
registerDavProperty('nc:download-url-expiration', { nc: 'http://nextcloud.org/ns' })
80+
registerDavProperty('oc:downloadURL', { oc: 'http://owncloud.org/ns' })
7881

7982
initLivePhotos()

apps/files/src/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,11 @@ export type Capabilities = {
147147
versioning: boolean
148148
}
149149
}
150+
151+
export type PreviewMetadata = {
152+
width: int,
153+
height: int,
154+
cropped: boolean,
155+
preview_url: string | null,
156+
preview_url_expiration: int | null,
157+
}

0 commit comments

Comments
 (0)