Skip to content

Commit

Permalink
feat: add support for webp contact avatars
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
  • Loading branch information
st3iny committed Oct 28, 2024
1 parent 3e9a167 commit e41a2e1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/components/ContactDetails/ContactDetailsAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down

0 comments on commit e41a2e1

Please sign in to comment.