forked from domix/avatarplugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
85 lines (51 loc) · 2.56 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Note:
The official documentation is locate at: http://www.grails.org/Avatar+Plugin
This plugin provides a taglib for displaying avatars. At the moment we only support gravatars (globally-recognized avatars).
Gravatars allow users to configure an avatar to go with their email address at a central location: gravatar.com. Gravatar-aware websites can then look up and display each user‘s preferred avatar, without having to handle avatar management. The user gets the benefit of not having to set up an avatar for each site that they post on.
==Code==
Plugin code is located at GitHub http://github.com/domix/avatarplugin/tree/master
==Installation==
'grails install-plugin avatar'
==Usage==
The plugin usage is quite simple.
'For Gravatar image'
Example: <avatar:gravatar email="${user.email}"/>
The tagLib will generate the following HTML code:
<img alt="Gravatar" class="avatar" height="20" src="https://secure.gravatar.com/avatar/f2f68f9b5281cd7c2eb7eecba1" width="20" />
As you can see, the taglib will generate some html default attributes like:
* id & name
* heigth & width
* CSS class
* alt
You can customize this default values as follows:
<avatar:gravatar email="${user.email}" alt="My Avatar" cssClass="myCss" size="50"/>
Output:
<img alt="My Avatar" class="myCss" height="50" src="https://secure.gravatar.com/avatar/f2f68f9b2814cd7c2eb7eecb9c" width="50" />
Alternatively you can customize default avatar to users who don't have a Gravatar Account:
<avatar:gravatar email="${user.email}" defaultGravatarUrl="${'http://mydomain.com/images/default-gravatar-80.png'.encodeAsURL()}" />
Also can be set the Gravatar rating:
<avatar:gravatar email="${user.email}" gravatarRating="G" />
'For twitter image'
Example: <avatar:twitter user="${user.twitter}"/>
Output:
<img alt='twitter' class='avatar' height='50' width='50' src='http://a0.twimg.com/profile_images/1124040897/at-twitter_normal.png' title='twitter'/>
You can customize:
* heigth & width
* CSS class
* alt
'For facebook image'
Example: <avatar:facebook user="${user.facebookId}"/>
Output:
<img alt='facebook' class='avatar' height='50' width='50' src='https://graph.facebook.com/facebook/picture' title='facebook'/>
You can customize:
* heigth & width
* CSS class
* alt
==Configuration==
To avoid expensive configuration each time plugin usage, you can configure global settings as follows:
In Config.groovy for Gravatar service
avatarPlugin {
defaultGravatarUrl="""http://yourdomain.com/images/default-gravatar-80.png"""
gravatarRating="G"
}
To use twitter and/or facebook avatars you don't need configuration