Skip to content

Commit

Permalink
Merge pull request #4199 from nextcloud/feat/webp-avatars
Browse files Browse the repository at this point in the history
feat: add support for webp contact avatars
  • Loading branch information
SebastianKrupinski authored Oct 30, 2024
2 parents d9304c8 + e41a2e1 commit 7ffc168
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 7ffc168

Please sign in to comment.