git ssb

0+

dangerousbeans / patchbay-bootstrap



Tree: 53cf077425b3a9a22877b44e927c7bcc36fb08e8

Files: 53cf077425b3a9a22877b44e927c7bcc36fb08e8 / modules / avatar-image.js

785 bytesRaw
1
2var getAvatar = require('ssb-avatar')
3var h = require('hyperscript')
4var ref = require('ssb-ref')
5
6var plugs = require('../plugs')
7var sbot_links = plugs.first(exports.sbot_links = [])
8var blob_url = require('../plugs').first(exports.blob_url = [])
9
10var id = require('../keys').id
11
12var default_avatar = '&qjeAs8+uMXLlyovT4JnEpMwTNDx/QXHfOl2nv2u0VCM=.sha256'
13
14exports.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