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.