This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2020-10-15 15:41:41 -07:00
|
|
|
<template>
|
2020-10-16 11:17:50 -07:00
|
|
|
<img :src="gravatar" alt="" class="rounded-circle"/>
|
2020-10-15 15:41:41 -07:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import md5 from 'js-md5';
|
|
|
|
import { Base64 } from 'js-base64';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
user: { required: true },
|
2020-10-16 11:17:50 -07:00
|
|
|
size: { 'default': 128 }
|
2020-10-15 15:41:41 -07:00
|
|
|
},
|
2020-10-16 11:17:50 -07:00
|
|
|
computed: {
|
2020-10-15 15:41:41 -07:00
|
|
|
gravatar(email, size = 128) {
|
2020-10-16 11:17:50 -07:00
|
|
|
const fallback = `https://avi.avris.it/${this.size}/${Base64.encode(this.user.username).replace(/\+/g, '-').replace(/\//g, '_')}.png`;
|
2020-10-15 15:41:41 -07:00
|
|
|
|
2020-10-16 11:17:50 -07:00
|
|
|
return `https://www.gravatar.com/avatar/${this.user.emailHash || md5(this.user.email)}?d=${encodeURIComponent(fallback)}&s=${this.size}`;
|
2020-10-15 15:41:41 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
$size: 6rem;
|
|
|
|
img {
|
|
|
|
width: 100%;
|
|
|
|
max-width: $size;
|
|
|
|
max-height: $size;
|
|
|
|
}
|
|
|
|
</style>
|