From e41a2e1cd347eb6e417ae508aafd7021f1b56920 Mon Sep 17 00:00:00 2001 From: Richard Steinmetz Date: Mon, 28 Oct 2024 13:47:22 +0100 Subject: [PATCH] feat: add support for webp contact avatars Signed-off-by: Richard Steinmetz --- .../ContactDetails/ContactDetailsAvatar.vue | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/ContactDetails/ContactDetailsAvatar.vue b/src/components/ContactDetails/ContactDetailsAvatar.vue index 6a0f1f007..ee399339b 100644 --- a/src/components/ContactDetails/ContactDetailsAvatar.vue +++ b/src/components/ContactDetails/ContactDetailsAvatar.vue @@ -309,12 +309,20 @@ export default { */ getMimetype(uint) { const bytes = [] - uint.slice(0, 4).forEach((byte) => { - bytes.push(byte.toString(16)) + uint.slice(0, 12).forEach((byte) => { + bytes.push(byte.toString(16).padStart(2, '0')) }) const hex = bytes.join('').toUpperCase() - switch (hex) { + const nextcloudMajorVersion = parseInt(window.OC.config.version.split('.')[0]) + if (nextcloudMajorVersion >= 31 + && hex.slice(0, 8) === '52494646' + && hex.slice(16, 24) === '57454250' + ) { + return 'image/webp' + } + + switch (hex.slice(0, 8)) { case '89504E47': return 'image/png' case '47494638':