@@ -26,6 +26,7 @@ import { getCapabilities } from '@nextcloud/capabilities'
2626import { onMounted , ref , watch } from ' vue'
2727
2828import NcLoadingIcon from ' @nextcloud/vue/components/NcLoadingIcon'
29+ import type { NextcloudCapabilities } from ' ../../types/capabilities'
2930
3031type AxiosImageResponse = {
3132 data: ArrayBuffer | string
@@ -61,8 +62,10 @@ const emit = defineEmits<{
6162const loading = ref (true )
6263const isLoaded = ref (false )
6364const imageData = ref (' ' )
64- const width = ref (getCapabilities ().libresign .config [' sign-elements' ].width )
65- const height = ref (getCapabilities ().libresign .config [' sign-elements' ].height )
65+ const capabilities = getCapabilities () as NextcloudCapabilities
66+ const signElementsConfig = capabilities .libresign ?.config [' sign-elements' ]
67+ const width = ref (` ${Number (signElementsConfig ?.[' signature-width' ] ?? 0 )}px ` )
68+ const height = ref (` ${Number (signElementsConfig ?.[' signature-height' ] ?? 0 )}px ` )
6669
6770async function loadImage() {
6871 if (props .src .startsWith (' data:' )) {
@@ -83,7 +86,9 @@ async function loadImage() {
8386
8487 try {
8588 const response = await axios (config ) as AxiosImageResponse
86- const buffer = Buffer .from (response .data , ' binary' ).toString (' base64' )
89+ const buffer = typeof response .data === ' string'
90+ ? Buffer .from (response .data , ' binary' )
91+ : Buffer .from (response .data )
8792 imageData .value = ` data:${response .headers [' content-type' ]};base64,${buffer } `
8893 onImageLoad (true )
8994 } catch {
0 commit comments