Files: 53cf077425b3a9a22877b44e927c7bcc36fb08e8 / modules / avatar-image.js
785 bytesRaw
1 | |
2 | var getAvatar = require('ssb-avatar') |
3 | var h = require('hyperscript') |
4 | var ref = require('ssb-ref') |
5 | |
6 | var plugs = require('../plugs') |
7 | var sbot_links = plugs.first(exports.sbot_links = []) |
8 | var blob_url = require('../plugs').first(exports.blob_url = []) |
9 | |
10 | var id = require('../keys').id |
11 | |
12 | var default_avatar = '&qjeAs8+uMXLlyovT4JnEpMwTNDx/QXHfOl2nv2u0VCM=.sha256' |
13 | |
14 | exports.avatar_image = function (author, classes) { |
15 | classes = classes || '' |
16 | if(classes && 'string' === typeof classes) classes = '.avatar--'+classes |
17 | |
18 | var img = h('img'+classes, {src: blob_url(default_avatar)}) |
19 | getAvatar({links: sbot_links}, id, author, function (err, avatar) { |
20 | if (err) return console.error(err) |
21 | if(ref.isBlob(avatar.image)) |
22 | img.src = blob_url(avatar.image) |
23 | }) |
24 | return img |
25 | } |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 |
Built with git-ssb-web