Aww (aww v1.0.0)
Summary
Functions
Generate URL for avatar using given service.
Types
Link to this type
avatar_opt()
Link to this type
host()
Link to this type
opts()
@type opts() :: [avatar_opt() | {:service_opts, [service_opt()]}]
Link to this type
service_opt()
@type service_opt() :: {:host, host()} | {:secure?, boolean()} | {:resolv_opts, [:inet_res.res_option()]} | {:timeout, pos_integer()} | {atom(), term()}
Functions
Link to this function
avatar_url(email, opts \\ [])
Generate URL for avatar using given service.
Options
Gravatar options supported are:
:size
- pixel size of the resulting image. As returned avatars are always squares, only one side is needed.:default
- fallback image and/or implementation for image generation. Check out your implementation documentation for list of supported values.:robohash
- Libravatar and Gravatar support using additional option fordefault: :robohash
.:forcedefault?
- force using default image (useful for testing):rating
- require image of this rating or lower. Used for explicit image filtering. Ignored by Libravatar (that service requires all images to bePG
rated).
Service options
It is possible to configure used service via options under :service_opts
configuration key. Recognised options are:
:host
- implementation that will be used for generating avatar. Possible options are::gravatar
- Gravatar:libravatar
- Libravatar - federated and open source service providing Gravatar-compatible API- 2-ary function passed either as a capture or
{m, f, a}
tuple. In case of MFA tuple the arguments will be prepended to passed list. Arguments appended are: domain of theemail
andopts
passed to this function. Defaults toApplication.get_env(:aww, :default, :libravatar)
.
:secure?
- whether to use secure (HTTPS) connection to the service. Defaults totrue
.:resolv_opts
- used byhost: :libravatar
- additional opts passed to DNS resolver. See:inet_res.res_option/0
for details.:timeout
- DNS query timeout in milliseconds. Defaults to5000
(5 seconds).