1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/app/helpers/gravatar.js
Naz Gargol ab2ef2d8d4
🎨 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

20 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}`;
}
});