I’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.
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 Magic Fields WordPress plugin.
I created a new MF custom panel called ‘Review’ and added a field called ‘Cover’ with the type of ‘Image (Upload Media)’. Then I used get_image(‘cover’, 1, 1, 1, $post_id, ‘h=150&w=150’) to retrieve the image in my theme. This seems to do a ‘zoom-crop’, which is a term I haven’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.
There’s a zoom crop option, that can be forced off. I tried that: get_image(‘cover’, 1, 1, 1, $post_id, ‘h=150&w=150&zc=0’). The result is the upper left corner of the cover.
The solution as reported by Brandon Sorg 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:
// 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 ); }
MF_thumb.txt 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.
After that, the zc=0 in get_image must still be used: get_image(‘cover’, 1, 1, 1, $post_id, ‘h=150&w=150&zc=0’)
The next time you upgrade Magic Fields to a new version, your changes will be overwritten. Hopefully they’ll have fixed the problem by then. If not, you’ll need to re-do the changes. Which is why I hate hate hate fixing bugs by hacking around someone’s original code. I do not like forking.
In a somewhat previous life, I used to write software. At this point it’s been years since I’ve written a line of production code. But I still poke around every once in a while. I’ve even coded up some plugins that I use on Rat’s Reading. Most are very specific to that site, such as adding in my Amazon associates tag automatically. Not really releasable stuff.
Both on that site and this one, I use Simple Tags to manage my tags. Pretty good plugin. However, one of my irritations both with that plugin’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 this post for a good explanation.
Anyway, I took the ideas from that blog post and hacked the Simple Tags tag cloud implementation on Rat’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’t lose my changes every time I upgraded.
I couldn’t find a standalone tag cloud plugin that implements logarithmic scaling. So I just wrote one. And here’s version 1.0 (beta). It’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’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’s currently not good enough to replace my modified Simple Tags tag cloud.