From 0290d113cd52d6b3c96f4bf182200a20fbc97fb1 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 --- src/components/ContactDetails/ContactDetailsAvatar.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/ContactDetails/ContactDetailsAvatar.vue b/src/components/ContactDetails/ContactDetailsAvatar.vue index 6a0f1f007f..a5ce68b318 100644 --- a/src/components/ContactDetails/ContactDetailsAvatar.vue +++ b/src/components/ContactDetails/ContactDetailsAvatar.vue @@ -309,12 +309,16 @@ 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) { + if (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':