<?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>Gravatar Archives - gj</title>
	<atom:link href="https://blog.gaiterjones.com/tag/gravatar/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.gaiterjones.com/tag/gravatar/</link>
	<description>gaiterjones</description>
	<lastBuildDate>Fri, 25 Feb 2011 16:00:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.3</generator>
	<item>
		<title>Integrating a Gravatar image into Magento</title>
		<link>https://blog.gaiterjones.com/gravatar-magento-integration/</link>
					<comments>https://blog.gaiterjones.com/gravatar-magento-integration/#respond</comments>
		
		<dc:creator><![CDATA[PAJ]]></dc:creator>
		<pubDate>Wed, 02 Feb 2011 11:10:31 +0000</pubDate>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[Gravatar]]></category>
		<guid isPermaLink="false">http://blog.gaiterjones.com/?p=60</guid>

					<description><![CDATA[Gravatar (an abbreviation for globally recognized avatar) is a service for providing globally-unique avatars which was created by Tom Preston-Werner. Here is a simple way to integrate the Gravatar of a customer (if...<a class="more-link" href="https://blog.gaiterjones.com/gravatar-magento-integration/" title="Continue reading">Continue reading</a>]]></description>
										<content:encoded><![CDATA[<p><a href="http://www.gravatar.com">Gravatar </a>(an abbreviation for <em>globally recognized avatar</em>) is a service for providing globally-unique avatars which was created by Tom Preston-Werner. Here is a simple way to integrate the Gravatar of a customer (if they have one) into your Magento eCommerce store to give a bit of an extra personal touch to your customers experience.</p>
<figure id="attachment_61" aria-describedby="caption-attachment-61" style="width: 534px" class="wp-caption aligncenter"><img fetchpriority="high" decoding="async" class="hang-1-column   " style="border: 1px solid black;" title="Magento shop header with integrated Customer Gravatar" src="https://blog.gaiterjones.com/wp-content/uploads/2011/02/Image1.jpg" alt="Magento shop header with integrated Customer Gravatar" width="534" height="160" /><figcaption id="caption-attachment-61" class="wp-caption-text">Magento shop header with integrated Customer Gravatar (Magento 1.4.2)</figcaption></figure>
<p>This example will place the Gravatar image next to the welcome message in the shop header.</p>
<p>Open <em>header.phtml</em> located in your themes <em>template/page/html/</em> folder and insert the following code:</p>
<pre class="brush:php">&lt;?php
/**
 * Get a Gravatar Image URL
 * Set the parameters to create a Gravatar image request
 * create Gravatar img URL if a valid Gravatar exists.
 * PAJ 02.02.2011
 */
$gravatar_img = '';
if (Mage::getSingleton('customer/session')-&gt;isLoggedIn()) {
	$gravatar_email = Mage::getSingleton('customer/session')-&gt;getCustomer()-&gt;getEmail();
	$gravatar_default = "404";
	$gravatar_rating = "g";
	$gravatar_size = 20;
	$gravatar_name = Mage::getSingleton('customer/session')-&gt;getCustomer()-&gt;getName();
	$gravatar_url = "https://secure.gravatar.com/avatar/" . md5( strtolower( trim( $gravatar_email ) ) ) . "?d=" . urlencode( $gravatar_default ) . "&amp;s=" . $gravatar_size . "&amp;r=" . $gravatar_rating;
	$gravatar_headers = get_headers($gravatar_url);
		if (!preg_match("|200|", $gravatar_headers[0])) {
			$gravatar_img = '';
		} else {
			$gravatar_img  = '&lt;img src="'. $gravatar_url. '" title="'. $gravatar_name. '" alt="'. $gravatar_name. '" style="float:left" /&gt; ';
		}
}
?&gt;</pre>
<p>Now look for the <em>quick access </em>DIV that calls the welcome message funtion <em>getWelcome()</em> and add in the Gravatar image URL. Note that Magento 1.4.2 adds some styling to the welcome message so you might want to style the Gravatar  too so it is placed better:</p>
<pre class="brush:php">&lt;?php echo $gravatar_img. $this-&gt;getWelcome() ?&gt;&lt;br /&gt;</pre>
<p>Thats it, the code uses the customers email address to create a valid MD5 encoded Gravatar image request, checks if a Gravatar exists and builds the URL to request the image in <em>$gravatar_img.</em> If a Gravatar exists it is displayed next to the welcome message and customers name. You could integrate the Gravatar elsewhere too, for example in the Customer Account Dashboard, or against customer comments, orders etc.</p>
<p>Further Gravatar development resources can be found <a href="http://en.gravatar.com/site/implement/">here</a>.<br />
Tested with Magento 1.3.3  and 1.4.2.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gaiterjones.com/gravatar-magento-integration/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
