Skip to content

ehousestudio/craft_gravatar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

#Gravatar for Craft CMS v 0.2

Craft CMS plugin allowing you to easily insert an avatar url or image from Gravatar based on email address.

##Parameters

  • email (required): The email address of the user
  • options (optional): Object of Gravatar settings

###Options

Option Type Default Description
size string 80 Size in pixels (Values: 1 - 2048)
default string mm Default imageset to use (Values: 404, mm, identicon, monsterid, wavatar)
rating string g Maximum rating (inclusive) (Values: g, pg, r, x)

##Usage

###.url()

Returns a Gravatar image URL with default settings to use within your own markup:

{{ craft.gravatar.url('email@domain.com') }}

This can also be used within the entry model:

{{ craft.gravatar.url(entry.author.email) }}

Lastly, it can be used with the user module:

Return all users' Gravatars:

{% set users = craft.users() %}

Return one user's Gravatar:

{% set users = craft.users({username: 'username'}) %}

Run the for loop for the set users:

{% for user in users %}
			
	{{ craft.gravatar.url(user.email) }}
	
{% endfor %}

Adding options:

{{ craft.gravatar.url('email@domain.com', {'size': '100', 'default': 'monsterid'}) }}

###.img()

Returns a Gravatar image in an <img> tag:

{{ craft.gravatar.img('email@domain.com') }}

The .img() method has an additional option:

Option Type Default Description
attr object null Additional key/value attributes to include in the IMG tag (optional)

Users loop with additional attributes:

{% set users = craft.users() %}
	
{% for user in users %}
	
	{{ craft.gravatar.img(user.email, {'attr': {'class': 'gravitated', 'id': 'author-' ~ user.id}}) }}
	
{% endfor %}	

##Feedback?

Contact us on Twitter: @ehousestudio

##License

This work is licenced under the MIT license.

About

Craft CMS plugin allowing you to easily insert an avatar URL or image from Gravatar.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages