<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WP Engineer &#187; Gravatar</title>
	<atom:link href="http://wpengineer.com/tag/gravatar/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com</link>
	<description>WordPress News, Hacks, Tips, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Sun, 22 Jan 2012 13:32:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Add Avatar To WordPress Default</title>
		<link>http://wpengineer.com/502/add-avatar-to-wordpress-default/</link>
		<comments>http://wpengineer.com/502/add-avatar-to-wordpress-default/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 18:24:12 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Avatar]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[Gravatar]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=502</guid>
		<description><![CDATA[Avatars are popular as identification and with the service Gravatar it is largely used in the comment area of different applications. WordPress allows the user some basic settings. For example loading a default or generated Avatar, if the commentator doesn't have one. Various themes have a standard Avatar to match the design. But even here [...]]]></description>
			<content:encoded><![CDATA[<p>Avatars are popular as identification and with the service Gravatar it is largely used in the comment area of different applications.<br />
WordPress allows the user some basic settings. For example loading a default or generated Avatar, if the commentator doesn't have one.<br />
Various themes have a standard Avatar to match the design. But even here there is a nice solution via a hook, which enables to add an avatar in the list of your backend to make a selection quite simple. In the following I would like to show with a short and simple code snippet how to add 2 new avatars to the array of WordPress.</p>
<p><a href="http://wpengineer.com/wp-content/uploads/addavatar.png"><img src="http://wpengineer.com/wp-content/uploads/addavatar-300x256.png" alt="addavatar" title="addavatar" width="300" height="256" class="aligncenter size-medium wp-image-619" /></a></p>
<p>You have to add this little function to <code>functions.php</code> of your theme and it will add 2 Avatar from your folder <code>images</code> of your theme directory. I suggest, that the Avatars have a size of 60 pixel.</p>
<pre lang="php">/**
 * add a default-gravatar to options
 */
if ( !function_exists(&#039;fb_addgravatar&#039;) ) {
	function fb_addgravatar( $avatar_defaults ) {
		$myavatar = get_bloginfo(&#039;template_directory&#039;) . &#039;/images/avatar.gif&#039;;
		$avatar_defaults&#091;$myavatar&#093; = &#039;people&#039;;

		$myavatar2 = get_bloginfo(&#039;template_directory&#039;) . &#039;/images/myavatar.png&#039;;
		$avatar_defaults&#091;$myavatar2&#093; = &#039;wpengineer.com&#039;;

		return $avatar_defaults;
	}

	add_filter( &#039;avatar_defaults&#039;, &#039;fb_addgravatar&#039; );
}</pre>
<p>Is the theme active, you will have the 2 new Avatars available in your list.<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/502/add-avatar-to-wordpress-default/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>Identify Authors With Gravatars</title>
		<link>http://wpengineer.com/505/identify-authors-gravatars/</link>
		<comments>http://wpengineer.com/505/identify-authors-gravatars/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 13:13:07 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Avatar]]></category>
		<category><![CDATA[Gravatar]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Themes]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=505</guid>
		<description><![CDATA[Since WordPress version 2.5, it is easier to include the Gravatar of a comment author in the comments. WordPress offers a feature that is easy to use and it brings some parameters with. In order to use and how to include a Gravatar, I would refer to the article &#8222;Gravatar Use Easy&#8220;. But with this [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/ad516503a11cd5ca435acc9bb6523536.jpeg" alt="" title="ad516503a11cd5ca435acc9bb6523536" width="80" height="80" class="alignright size-full wp-image-504" /><br />
Since WordPress version 2.5, it is easier to include the Gravatar of a comment author in the comments. WordPress offers a feature that is easy to use and it brings some parameters with. In order to use and how to include a Gravatar, I would refer to the article &#8222;<a href="http://wpengineer.com/gravatars-use-easy/">Gravatar Use Easy</a>&#8220;.</p>
<p>But with this feature you can do more. Magazine-style for blogs are currently in high demand and many blogs have a a couple of authors. Many times the blogs link and present the author of the respective contribution. WP offers a whole range of template tags to this functionality, <a href="http://codex.wordpress.org/Template_Tags#Author_tags">check out Codex</a>.</p>
<p>Now it would be nice to give the author a face.<span id="more-505"></span> You can do that with the Plugin &#8222;<a href="http://horttcore.de/2008/02/02/extended-userprofil/">Extended User Profile</a>&#8220; and enter more information in the backend of WordPress.</p>
<p>Alternatively you can load the Gravatar of the author. The Gravatar function <code>get_avatar()</code> works great in the loop of WP and you just have to assign the email address. It's easily done by the template tag <code>get_the_author_email()</code>.</p>
<pre lang="php">
&lt;?php
$author = get_the_author_email();
echo get_avatar( $author, 80 );
?&gt;
</pre>
<p>This above code creates this:</p>
<pre lang="php">
&lt;img alt=&#039;&#039; src=&#039;http://www.gravatar.com/avatar/md5-Schlüssel_des_gravatar?s=80&amp;d=http%3A%2F%2Fwww.gravatar.com%2Favatar%2Fmd5-Schlüssel_des_gravatar%3Fs%3D80&amp;r=G&#039; class=&#039;avatar avatar-80&#039; height=&#039;80&#039; width=&#039;80&#039; /&gt;
</pre>
<p>Alternatively you can get the email directly, with any variables.</p>
<pre lang="php">
&lt;?php echo get_avatar( get_the_author_email(), 80 ); ?&gt;
</pre>
<p>Use CSS to format, you can use the class <code>avatar</code>, which is also assigned to the comments. Simultaneously there is also a class, which is created in regard to the Gravatar size, for the above syntax it would be <code>avatar-80</code>. So it's possible to format the picture of the author with this class.<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/505/identify-authors-gravatars/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Gravatars Use Easy</title>
		<link>http://wpengineer.com/507/gravatars-use-easy/</link>
		<comments>http://wpengineer.com/507/gravatars-use-easy/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 18:09:46 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Avatar]]></category>
		<category><![CDATA[Comment]]></category>
		<category><![CDATA[Gravatar]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Themes]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=507</guid>
		<description><![CDATA[Since version 2.5 of WordPress, Gravatar service is included in the core files. On one hand, you can use it to make the comment overview more nicely. But you can also integrate this function in your template and you don't have to use a Plugin. You just have to insert the following syntax and the [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/ad516503a11cd5ca435acc9bb6523536.jpeg" alt="" title="ad516503a11cd5ca435acc9bb6523536" width="80" height="80" class="alignright size-full wp-image-504" /><br />
Since version 2.5 of WordPress, <a href="http://en.gravatar.com/">Gravatar service</a> is included in the core files. On one hand, you can use it to make the comment overview more nicely. But you can also integrate this function in your template and you don't have to use a Plugin.<br />
<span id="more-507"></span><br />
You just have to insert the following syntax and the little pictures will be displayed in your comment area of your theme.</p>
<pre lang="php">
&lt;?php if(function_exists(&#039;get_avatar&#039;)) {
	echo get_avatar( $comment );
} ?&gt;
</pre>
<p>The function <code>get_avatar()</code> (<code>/wp-includes/pluggable.php</code>) has 3 parameters, so you can adjust it easily to your liking.</p>
<ul>
<li><code>$id_or_email</code> Mail address or ID of the users, commentators</li>
<li><code>$size</code> Size of the Gravatars in pixel</li>
<li><code>$default</code> Default image, if the user doesn't have a Gravatar yet</li>
</ul>
<pre lang="php">
get_avatar( $id_or_email, $size = &#039;96&#039;, $default = &#039;&#039; )
</pre>
<p>As default Gravatar it loads http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536 , this is the icon for the email address unknown@gravatar.com (MD5 verschlüsselt: d516503a11cd5ca435acc9bb6523536). The default size is 96 Pixel. You just have to assign the first parameter or variable.</p>
<p>The output would look like this:</p>
<pre lang="php">
&lt;img alt=&#039;&#039; src=&#039;http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96&#039; class=&#039;avatar avatar-96 avatar-default&#039; height=&#039;96&#039; width=&#039;96&#039; /&gt;
</pre>
<p>Thus you can adjust the design with the help of CSS. The class <code>avatar</code> is available. Also you can use the class for the size of the Gravatar: <code>avatar-size</code>. Varied formattings are possible.</p>
<h3>How to implement?</h3>
<p>Since many people asking how to implement it, here is a short instruction for non-PHPler.</p>
<p>The code has to be in <code>comments.php</code>, it displays the comments and comment form. Of course it can be different, but in most themes it will be like that.</p>
<p>The function has to be in every output of each comment, that means it has to be within the loop <code>&lt;?php foreach ($comments as $comment) : &gt;</code> .<br />
Normally after the <code>li</code>, which displays every comment.</p>
<h4>Search:</h4>
<pre lang="php">
  &lt;ol class=&quot;commentlist&quot;&gt;

    &lt;?php foreach ($comments as $comment) : ?&gt;

       &lt;li &lt;?php echo $oddcomment; ?&gt;id=&quot;comment-&lt;?php comment_ID() ?&gt;&quot;&gt;
</pre>
<h4>Replace:</h4>
<pre lang="php">
  &lt;ol class=&quot;commentlist&quot;&gt;

    &lt;?php foreach ($comments as $comment) : ?&gt;

      &lt;li &lt;?php echo $oddcomment; ?&gt;id=&quot;comment-&lt;?php comment_ID() ?&gt;&quot;&gt;
        &lt;?php echo get_avatar( $comment, 32 ); ?&gt;
</pre>
<p>Some themes aren't using a list (<code>ol</code> or <code>ul</code>); the output gets create by <code>div</code>. The important thing is, it has to be in the loop.</p>
<pre lang="php">
&lt;?php foreach ($comments as $comment) : ?&gt;
. . .
&lt;?php endforeach; /* end for each comment */ ?&gt;
</pre>
<h4>Format via CSS</h4>
<p>The format could look like that. This syntax goes to the <code>style.css</code> of your used theme.</p>
<pre lang="css">
.commentlist li .avatar {
	float: right;
	border: 1px solid #eee;
	padding: 2px;
	background: #fff;
	}
</pre>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/507/gravatars-use-easy/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

