{% macro gravatar(user, size) -%}
{% if user.preferences.email_address %}
{% if size %}
<img src="{{g.gravatar(user.preferences.email_address, default=g.url('/u/'+user.username.replace('_', '-')+'/user_icon'))}}"
alt="{{user.display_name}}"
title="{{user.display_name}}"
height="{{size}}"
width="{{size}}"/>
{% else %}
<img src="{{g.gravatar(user.preferences.email_address, default=g.url('/u/'+user.username.replace('_', '-')+'/user_icon'))}}"
alt="{{user.display_name}}"
title="{{user.display_name}}"/>
{% endif %}
{% else %}
{% if size %}
<img src="{{'/u/'+user.username.replace('_', '-')+'/user_icon'}}"
alt="{{user.display_name}}"
title="{{user.display_name}}"
height="{{size}}"
width="{{size}}"/>
{% else %}
<img src="{{'/u/'+user.username.replace('_', '-')+'/user_icon'}}"
alt="{{user.display_name}}"
title="{{user.display_name}}"/>
{% endif %}
{% endif %}
{%- endmacro %}
{% macro email_gravatar(email, title=None, size=None) -%}
{% if email %}
<img src="{{g.gravatar(email, size=size)}}" alt="{{title or email}}" title="{{title or email}}"{% if size %} width="{{size}}" height="{{size}}"{% endif %}/>
{% else %}
<img src="{{g.forge_static('images/user.png')}}" alt="{{title}}" title="{{title}}"{% if size %} width="{{size}}" height="{{size}}"{% endif %}/>
{% endif %}
{%- endmacro %}