git ssb

0+

ev / microbay



forked from Dominic / patchbay

Tree: 896d9cb98b2e5f5c21d03292502be08b22a16f1a

Files: 896d9cb98b2e5f5c21d03292502be08b22a16f1a / 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