<?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>King Rat &#187; Code</title>
	<atom:link href="http://www.kingrat.us/category/code/feed" rel="self" type="application/rss+xml" />
	<link>http://www.kingrat.us</link>
	<description>Private Life</description>
	<lastBuildDate>Sun, 22 Jan 2012 04:34:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Magic Fields proportional image resizing bug</title>
		<link>http://www.kingrat.us/2011/02/magic-fields-proportional-image-resizing-bug</link>
		<comments>http://www.kingrat.us/2011/02/magic-fields-proportional-image-resizing-bug#comments</comments>
		<pubDate>Thu, 17 Feb 2011 01:51:34 +0000</pubDate>
		<dc:creator>King Rat</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.kingrat.us/?p=20032</guid>
		<description><![CDATA[I&#8217;m posting this in the hope that it becomes sufficiently Google ranked that other folks who have had the problem can find the answer explain, as the sources of this information were buried in a Google Group and were not &#8230; <a href="http://www.kingrat.us/2011/02/magic-fields-proportional-image-resizing-bug">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m posting this in the hope that it becomes sufficiently Google ranked that other folks who have had the problem can find the answer explain, as the sources of this information were buried in a Google Group and were not complete answers.</p>

<p>I am attempting to build a new book review blog.  I want to have book cover images attached to posts, as well as a lot of other meta-data.  My current plan is to use the <a href="http://www.magicfields.org/" >Magic Fields WordPress plugin</a>.</p>

<p>I created a new MF custom panel called &#8216;Review&#8217; and added a field called &#8216;Cover&#8217; with the type of &#8216;Image (Upload Media)&#8217;.  Then I used get_image(&#8216;cover&#8217;, 1, 1, 1, $post_id, &#8216;h=150&amp;w=150&#8242;) to retrieve the image in my theme.  This seems to do a &#8216;zoom-crop&#8217;, which is a term I haven&#8217;t heard before (call me clueless).  What I got was an image that where the smallest dimension (in this case, the width) was reduced to 150, and the extra from the other dimension is just cropped off.  What I want is for both height and width to be reduced until both are below 150.</p>

<p>There&#8217;s a zoom crop option, that can be forced off.  I tried that: get_image(&#8216;cover&#8217;, 1, 1, 1, $post_id, &#8216;h=150&amp;w=150&amp;zc=0&#8242;). The result is the upper left corner of the cover.</p>

<p>The solution <a href="http://groups.google.com/group/magic-fields/msg/dd8b4a7fa06869d2" >as reported by Brandon Sorg</a> is to replace part of the code of of the Magic Field file MF_thumb.php.  Lines 118 to 174 of the original file get replaced with this much smaller piece of code:</p>

<pre>
	        // don't crop, just resize using $dest_w x $dest_h as a maximum bounding box 
	        $crop_w = $orig_w; 
	        $crop_h = $orig_h; 
	        $s_x = 0; 
	        $s_y = 0; 
	        list( $new_w, $new_h ) = wp_constrain_dimensions( $orig_w, $orig_h, $dest_w, $dest_h ); 
        }
</pre>

<p><a href="http://www.kingrat.us/wp-content/uploads/2011/02/MF_thumb.txt" >MF_thumb.txt</a> is the complete file (with .php replaced with .txt). Download, rename to MF_thumb.php and copy over the file in your plugins/magic-fields directory.  Please check the contents of the file and verify them yourself, as I take no responsibility if it does not work as intended.</p>

<p>After that, the zc=0 in get_image must still be used: get_image(&#8216;cover&#8217;, 1, 1, 1, $post_id, &#8216;h=150&amp;w=150&amp;zc=0&#8242;)</p>

<p>The next time you upgrade Magic Fields to a new version, your changes will be overwritten. Hopefully they&#8217;ll have fixed the problem by then.  If not, you&#8217;ll need to re-do the changes. Which is why I hate hate hate fixing bugs by hacking around someone&#8217;s original code. I do not like forking.</p>]]></content:encoded>
			<wfw:commentRss>http://www.kingrat.us/2011/02/magic-fields-proportional-image-resizing-bug/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Log Cloud 1.0 beta</title>
		<link>http://www.kingrat.us/2009/01/log-cloud-10-beta</link>
		<comments>http://www.kingrat.us/2009/01/log-cloud-10-beta#comments</comments>
		<pubDate>Fri, 30 Jan 2009 18:40:06 +0000</pubDate>
		<dc:creator>King Rat</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[log cloud]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[tags]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.kingrat.us/?p=516</guid>
		<description><![CDATA[In a somewhat previous life, I used to write software. At this point it&#8217;s been years since I&#8217;ve written a line of production code. But I still poke around every once in a while. I&#8217;ve even coded up some plugins &#8230; <a href="http://www.kingrat.us/2009/01/log-cloud-10-beta">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In a somewhat previous life, I used to write software.  At this point it&#8217;s been years since I&#8217;ve written a line of production code.  But I still poke around every once in a while.  I&#8217;ve even coded up some plugins that I use on <a href="http://reading.kingrat.biz/" >Rat&#8217;s Reading</a>. Most are very specific to that site, such as adding in my Amazon associates tag automatically.  Not really releasable stuff.</p>

<p>Both on that site and this one, I use <a href="http://wordpress.org/extend/plugins/simple-tags/" >Simple Tags</a> to manage my tags.  Pretty good plugin. However, one of my irritations both with that plugin&#8217;s tag cloud and the standard WordPress tag cloud are that they use linear scaling for font sizes.  In other words, if a site has one tag that has a disproportionate number of uses, the font sizing is worthless. See <a href="http://blogs.dekoh.com/dev/2007/10/29/choosing-a-good-font-size-variation-algorithm-for-your-tag-cloud/" >this post</a> for a good explanation.</p>

<p>Anyway, I took the ideas from that blog post and hacked the Simple Tags tag cloud implementation on Rat&#8217;s Reading to use logarithmic scaling.  But every version upgrade of Simple Tags overwrites that, which is a pain.  So I looked for a standalone tag cloud with this kind of scaling so I wouldn&#8217;t lose my changes every time I upgraded.</p>

<p>I couldn&#8217;t find a standalone tag cloud plugin that implements logarithmic scaling.  So I just wrote one. And here&#8217;s version 1.0 (beta). It&#8217;s very very simple.  Almost zero features.  Only way to get a tag cloud is via shortcode, and it only implements options in the standard WordPress tag cloud functions.  I&#8217;m throwing it out in case other folks want to play with similar stuff. I will add a few features over the next few weeks and versions, as it&#8217;s currently not good enough to replace my modified Simple Tags tag cloud.</p>

<p><a class="zip"  href="http://www.kingrat.us/wp-content/uploads/2009/01/logcloud-10-beta.zip" >Log Cloud 1.0 (beta)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kingrat.us/2009/01/log-cloud-10-beta/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

