<?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; Comment</title> <atom:link href="http://wpengineer.com/tag/comment/feed/" rel="self" type="application/rss+xml" /><link>http://wpengineer.com</link> <description>WordPress News, Hacks, Tipps, Tutorials, Plugins and Themes</description> <lastBuildDate>Wed, 28 Jul 2010 13:37:05 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=4840</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>Gravatars Use Easy</title><link>http://wpengineer.com/gravatars-use-easy/</link> <comments>http://wpengineer.com/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/blog/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/" class="liexternal">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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'get_avatar'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> get_avatar<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$comment</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div><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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;">get_avatar<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$id_or_email</span><span style="color: #339933;">,</span> <span style="color: #000088;">$size</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'96'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$default</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span> <span style="color: #009900;">&#41;</span></pre></div></div><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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>img alt<span style="color: #339933;">=</span><span style="color: #0000ff;">''</span> src<span style="color: #339933;">=</span><span style="color: #0000ff;">'http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96'</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'avatar avatar-96 avatar-default'</span> height<span style="color: #339933;">=</span><span style="color: #0000ff;">'96'</span> width<span style="color: #339933;">=</span><span style="color: #0000ff;">'96'</span> <span style="color: #339933;">/&gt;</span></pre></div></div><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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;">  &lt;ol class=&quot;commentlist&quot;&gt;
&nbsp;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$comments</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$comment</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
       &lt;li <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$oddcomment</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>id=&quot;comment-<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;</pre></div></div><h4>Replace:</h4><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;">  &lt;ol class=&quot;commentlist&quot;&gt;
&nbsp;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$comments</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$comment</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
      &lt;li <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$oddcomment</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>id=&quot;comment-<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> get_avatar<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$comment</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">32</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div><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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$comments</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$comment</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
. . .
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/* end for each comment */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div><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><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.commentlist</span> li <span style="color: #6666ff;">.avatar</span> <span style="color: #00AA00;">&#123;</span> 
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></div></div><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/identify-authors-gravatars/" rel="bookmark" title="Permanent Link: Identify Authors With Gravatars" class="liinternal">Identify Authors With Gravatars</a></li><li><a
href="http://wpengineer.com/easy-way-for-advertisement-in-wordpress/" rel="bookmark" title="Permanent Link: Easy Way For Advertisement In WordPress" class="liinternal">Easy Way For Advertisement In WordPress</a></li><li><a
href="http://wpengineer.com/customize-your-wordpress-feeds/" rel="bookmark" title="Permanent Link: Customize Your WordPress-Feeds" class="liinternal">Customize Your WordPress-Feeds</a></li><li><a
href="http://wpengineer.com/change-the-wordpress-message/" rel="bookmark" title="Permanent Link: Change the WordPress Message" class="liinternal">Change the WordPress Message</a></li><li><a
href="http://wpengineer.com/disable-wordpress-feed/" rel="bookmark" title="Permanent Link: Disable WordPress Feed" class="liinternal">Disable WordPress Feed</a></li></ul><hr
/><p><img
style="float:left;" src="http://wpengineer.com/favicon.ico" alt="WP Engineer Favicon"/> Thanks for subscribing our feed! <a
href="http://buysellads.com/buy/detail/3646/" class="liexternal">Sponsor the WP Engineer Blog</a> and get your brand in front of several hundred users per day!<br
/> &copy; <a
href="http://wpengineer.com/" class="liinternal">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p> ]]></content:encoded> <wfw:commentRss>http://wpengineer.com/gravatars-use-easy/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Database Caching 21/34 queries in 0.117 seconds using disk
Object Caching 460/525 objects using disk

Served from: wpengineer.com @ 2010-07-29 13:08:58 -->