Ghost/ghost/admin/app/helpers/gravatar.js
Naz Gargol 1df0e2b917 🎨 Added gravatars for member avatars (#1417)
no issue

- When an email has a valid gravatar handle it displays an image instead of initials for the member
- Introduces new {{gravatar}} helper which accepts an email as parameter and size/d as named parameters. The output is a URL to gravatar image
- Refactored usage of "splattribute" to explicit property. There was a need to duplicate class property usage in the component and doing that through splatttibute feature is unsafe as pointed ou here - https://github.com/TryGhost/Ghost-Admin/pull/1417#discussion_r351837584
2019-12-03 18:10:47 +07:00

21 lines
521 B
JavaScript

import Helper from '@ember/component/helper';
import md5 from 'blueimp-md5';
import {isEmpty} from '@ember/utils';
import {inject as service} from '@ember/service';
export default Helper.extend({
config: service(),
compute([email], {size = 180, d = 'blank'}/*, hash*/) {
if (!this.get('config.useGravatar')) {
return;
}
if (!email || isEmpty(email)) {
return;
}
return `https://www.gravatar.com/avatar/${md5(email)}?s=${size}&d=${d}`;
}
});