<?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>Smiths R Us &#187; WordPress</title>
	<atom:link href="http://smithsrus.com/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://smithsrus.com</link>
	<description>Technology, home automation, usability, and whatever else amuses me.</description>
	<lastBuildDate>Mon, 19 Jul 2010 17:38:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Detecting When Gravatar Has No Image</title>
		<link>http://smithsrus.com/detecting-when-gravatar-has-no-image/</link>
		<comments>http://smithsrus.com/detecting-when-gravatar-has-no-image/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 16:31:51 +0000</pubDate>
		<dc:creator>Doug Smith</dc:creator>
				<category><![CDATA[Gravatar]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[address book]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[photo]]></category>

		<guid isPermaLink="false">http://smithsrus.com/?p=149</guid>
		<description><![CDATA[[This information in this post is out of date. Please see Gravatar, AppleScript, and the OS X Address Book Revisited for more current information.] We&#8217;re on our way to building an AppleScript to update all of the contacts in your Mac Address Book with pictures from the Gravatar service. This is part 3 of the [...]]]></description>
			<content:encoded><![CDATA[<p><em>[This information in this post is out of date. Please see <a href="http://smithsrus.com/gravatar-applescript-and-the-os-x-address-book-revisited/">Gravatar, AppleScript, and the OS X Address Book Revisited</a> for more current information.]</em><br />
<hr />
<p>We&#8217;re on our way to building an <a href="http://www.apple.com/applescript/">AppleScript</a> to update all of the contacts in your Mac Address Book with pictures from the <a href="http://gravatar.com/">Gravatar</a> service. This is part 3 of the series.</p>
<p>Part 1, <a href="http://smithsrus.com/gravatar-applescript-and-address-book-pictures/">Gravatar, AppleScript, and Address Book Pictures</a>, introduced the topic and ended with a short AppleScript to construct a Gravatar URL given an e-mail address.</p>
<p>Then in part 2, <a href="http://smithsrus.com/setting-an-address-book-picture-with-applescript/">Setting an Address Book Picture with AppleScript</a>, we built a script showing how to successfully set a contact photo in Address Book.</p>
<p>Now we need to detect when the Gravatar service does not have an image on file for a given e-mail address.<span id="more-149"></span> The problem is that Gravatar does one of several things when it doesn&#8217;t have a matching image: return a default image, return an image you specify, or generate an image in one of several styles. But in every case it returns an image.</p>
<p>This is all well and good if you&#8217;re displaying Gravatars on a blog comments page. The Gravatar URL ends up inside an img tag and this keeps it dead simple. It&#8217;s also nice for everyone to get some kind of avatar even if they haven&#8217;t created one.</p>
<p>But for our purposes we don&#8217;t need a default image that ends up being attached to a contact. Not only does it clutter our contacts, but it would make it more difficult if we later wanted our script to only update contacts with no existing picture and leave the others alone.</p>
<p>Detecting a no match condition would also be useful in a WordPress plugin even if a default image was used. For example, I&#8217;ve always wanted to display some sort of indicator and a link to Gravatar for those who don&#8217;t have a Gravatar yet. If we can detect that a default image was used then we can set a CSS class on the image or do other creative things.</p>
<p>So how do we tell if there is no image match? It&#8217;s simple with a little undocumented trick in the Gravatar URL.</p>
<p>There is a d= parameter where we can specify a default image to return when there is no match. If we set that to null by using two empty URL encoded quotes then instead of a default image we get nothing. For example:</p>
<p><code></p>
<p>http://www.gravatar.com/avatar/1bc47906dcb8f3661bae9a8448e49a8a?d=%22%22</p>
<p></code></p>
<p>For our Address Book script we need to save the image to a file anyway so we just check for the existence of the file or a zero size. We can skip that entry or take other action if there is nothing there.</p>
<p>In the case of a WordPress plugin it might be less convenient because we may have to hit the Gravatar servers twice; once to check for a no match condition, then again to get the image with whatever default we actually want. Of course, if we use a local default file then it would still only be one call to the Gravatar service but that rules out using one of the cool generated defaults.</p>
<p>(If any of the Gravatar folks are listening, it would be great to have an option in the URL that means I&#8217;m using this for further processing and not in an img tag then also pass back some sort of status telling if the image is a default.)</p>
<p>Here&#8217;s a demonstration AppleScript that makes use of the above technique to download a Gravatar for a given e-mail address and take action only if there was a matched image: (<a href="applescript://com.apple.scripteditor?action=new&#038;script=--%20Download%20a%20Gravatar%20image%20and%20see%20if%20it%27s%20a%20match%20or%20default.%0D--%20Released%20under%20GPL.%0D--%20by%20Doug%20Smith%2C%20http%3A//smithsrus.com%0D%0D--%20The%20e-mail%20address%20to%20look%20up.%0Dset%20email%20to%20%22someone%40somewhere.com%22%0D%0D--%20Calculate%20an%20MD5%20for%20the%20e-mail%20address.%0Dset%20md5_email%20to%20do%20shell%20script%20%22md5%20-q%20-s%20%60echo%20%22%20%26%20email%20%26%20%22%20%7C%20tr%20%27%5B%3Aupper%3A%5D%27%20%27%5B%3Alower%3A%5D%27%60%22%0D%0D--%20Construct%20the%20Gravatar%20URL.%0Dset%20grav_url%20to%20quoted%20form%20of%20%28%22http%3A//gravatar.com/avatar/%22%20%26%20md5_email%20%26%20%22%3Fd%3D%22%20%26%20%22%2522%2522%22%20as%20text%29%0D%0D--%20Make%20a%20file%20name%20in%20which%20to%20temporarily%20save%20the%20Gravatar.%0Dset%20grav_file%20to%20%28path%20to%20temporary%20items%29%20%26%20%22gravatar%22%20%26%20md5_email%20%26%20%22.jpg%22%20as%20text%0Dset%20grav_POSIX_file%20to%20quoted%20form%20of%20POSIX%20path%20of%20grav_file%0D%0D--%20Download%20the%20Gravatar%20image%20to%20the%20temporary%20file%20with%20a%20timeout%20of%2010%20seconds.%0Ddo%20shell%20script%20%22curl%20%22%20%26%20grav_url%20%26%20%22%20-m%2010%20-o%20%22%20%26%20grav_POSIX_file%0D%0Dtell%20application%20%22System%20Events%22%0D%09if%20exists%20file%20grav_file%20then%0D%09%09tell%20me%20to%20display%20dialog%20%22Yes%2C%20we%20have%20a%20matching%20Gravatar%20downloaded%20to%20%22%20%26%20grav_POSIX_file%20%26%20%22.%22%20buttons%20%7B%22Okay%22%7D%20default%20button%201%0D%09%09delete%20file%20grav_file%0D%09else%0D%09%09tell%20me%20to%20display%20dialog%20%22Sorry%2C%20there%20was%20no%20matching%20Gravatar.%22%20buttons%20%7B%22Okay%22%7D%20default%20button%201%0D%09end%20if%0Dend%20tell%0D">Open in Script Editor</a>)</p>
<p><ins datetime="2009-03-25T17:21:43+00:00">(Updated with a small bug fix on 03/25/2009.)</ins><br />
<ins datetime="2009-04-23T13:56:48+00:00">(Updated on 04/23/2009 to remove my testing e-mail address and display the downloaded file path.)</ins></p>

<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">-- Download a Gravatar image and see if it's a match or default.</span>
<span style="color: #808080; font-style: italic;">-- Released under GPL.</span>
<span style="color: #808080; font-style: italic;">-- by Doug Smith, http://smithsrus.com</span>
&nbsp;
<span style="color: #808080; font-style: italic;">-- The e-mail address to look up.</span>
<span style="color: #ff0033; font-weight: bold;">set</span> email <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;someone@somewhere.com&quot;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">-- Calculate an MD5 for the e-mail address.</span>
<span style="color: #ff0033; font-weight: bold;">set</span> md5_email <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">do shell script</span> <span style="color: #009900;">&quot;md5 -q -s `echo &quot;</span> <span style="color: #000000;">&amp;</span> email <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; | tr '[:upper:]' '[:lower:]'`&quot;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">-- Construct the Gravatar URL.</span>
<span style="color: #ff0033; font-weight: bold;">set</span> grav_url <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">quoted form</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;http://gravatar.com/avatar/&quot;</span> <span style="color: #000000;">&amp;</span> md5_email <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;?d=&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;%22%22&quot;</span> <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">text</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">-- Make a file name in which to temporarily save the Gravatar.</span>
<span style="color: #ff0033; font-weight: bold;">set</span> grav_file <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">path to</span> temporary <span style="color: #0066ff;">items</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;gravatar&quot;</span> <span style="color: #000000;">&amp;</span> md5_email <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;.jpg&quot;</span> <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">text</span>
<span style="color: #ff0033; font-weight: bold;">set</span> grav_POSIX_file <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">quoted form</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">POSIX path</span> <span style="color: #ff0033; font-weight: bold;">of</span> grav_file
&nbsp;
<span style="color: #808080; font-style: italic;">-- Download the Gravatar image to the temporary file with a timeout of 10 seconds.</span>
<span style="color: #0066ff;">do shell script</span> <span style="color: #009900;">&quot;curl &quot;</span> <span style="color: #000000;">&amp;</span> grav_url <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; -m 10 -o &quot;</span> <span style="color: #000000;">&amp;</span> grav_POSIX_file
&nbsp;
<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;System Events&quot;</span>
	<span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #0066ff;">exists</span> <span style="color: #0066ff;">file</span> grav_file <span style="color: #ff0033; font-weight: bold;">then</span>
		<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">me</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">display dialog</span> <span style="color: #009900;">&quot;Yes, we have a matching Gravatar downloaded to &quot;</span> <span style="color: #000000;">&amp;</span> grav_POSIX_file <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;.&quot;</span> <span style="color: #0066ff;">buttons</span> <span style="color: #000000;">&#123;</span><span style="color: #009900;">&quot;Okay&quot;</span><span style="color: #000000;">&#125;</span> default button <span style="color: #000000;">1</span>
		<span style="color: #0066ff;">delete</span> <span style="color: #0066ff;">file</span> grav_file
	<span style="color: #ff0033; font-weight: bold;">else</span>
		<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">me</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">display dialog</span> <span style="color: #009900;">&quot;Sorry, there was no matching Gravatar.&quot;</span> <span style="color: #0066ff;">buttons</span> <span style="color: #000000;">&#123;</span><span style="color: #009900;">&quot;Okay&quot;</span><span style="color: #000000;">&#125;</span> default button <span style="color: #000000;">1</span>
	<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span></pre></div></div>

<p>Well, we&#8217;re almost to our goal of a <a href="http://smithsrus.com/filling-mac-address-book-pictures-with-gravatars/">script to automatically update all of our Address Book contacts with Gravatars</a>. I&#8217;ll put it all together next time in <a href="http://smithsrus.com/filling-mac-address-book-pictures-with-gravatars/">part 4</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://smithsrus.com/detecting-when-gravatar-has-no-image/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>WordPress Admin Color Scheme: Fresh Plus Visited</title>
		<link>http://smithsrus.com/wordpress-admin-color-scheme-fresh-plus-visited/</link>
		<comments>http://smithsrus.com/wordpress-admin-color-scheme-fresh-plus-visited/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 02:18:44 +0000</pubDate>
		<dc:creator>Doug Smith</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[color scheme]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[WordPress 2.5]]></category>

		<guid isPermaLink="false">http://smithsrus.com/?p=96</guid>
		<description><![CDATA[Although I like the new look of WordPress 2.5, I miss having the visited links in the dashboard shown as a different color. I like to keep up on the latest WordPress news and I previously relied on the link color to see what I had not yet read. Fortunately, WordPress 2.5 has a way [...]]]></description>
			<content:encoded><![CDATA[<p>Although I like the new look of WordPress 2.5, I miss having the visited links in the dashboard shown as a different color. I like to keep up on the latest WordPress news and I previously relied on the link color to see what I had not yet read.</p>
<p> <img class="aligncenter size-full wp-image-94" title="WordPress admin color scheme" src="http://smithsrus.com/wp-content/uploads/2008/04/admin-color-scheme.jpg" alt="WordPress admin color scheme" width="423" height="104" /></p>
<p>Fortunately, WordPress 2.5 has a way for plugins to add additional color schemes. So I whipped up a quick plugin to add the style necessary to mark those visited links in a different color. You can grab a copy from my <a title="Download page for the WordPress admin color scheme Fresh Plus Visited plugin." href="http://smithsrus.com/downloads/wordpress-admin-color-fresh-plus-visited/">downloads page for admin color scheme: <em>Fresh Plus Visited</em></a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://smithsrus.com/wordpress-admin-color-scheme-fresh-plus-visited/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)

Served from: smithsrus.com @ 2010-07-31 03:51:49 -->