Resize still broken in Magic Fields

86 views
Skip to first unread message

volderette

unread,
Sep 15, 2010, 3:57:12 AM9/15/10
to Magic Fields
Hello,

i use the following code to generate my images:


$pictures = get_field_duplicate('Preview');
$i = 0;
foreach($pictures as $picture){

$i++;

$previmage = simplexml_load_string(gen_image('Preview',
1,$i,array('h' => 600, 'w' => 800, 'zc' => 0, 'aoe' => 0)));
$lowres = simplexml_load_string(gen_image('Preview',
1,$i,array('h' => 1200, 'w' => 1200, 'zc' => 0, 'aoe' => 0, 'q' =>
95)));

echo "<li><a class='noicon' rel='fancybox' href='".
$previmage['src']."'><img src='".$picture['t']."' alt='".
$picstripped."' height='120px' width='170px'/></a>";
echo "<li><a href='".$picture['o']."' title='".$picstripped." High
Resolution' target='_blank'>high-res</a></li>";
echo "<li><a href='".$lowres['src']."' title='".$picstripped." Low
Resolution' target='_blank'>low-res</a></li>";

It used to work fine with an older version of MagicFields, but now the
images are not resized, but stretched.

I understand that you stripped phpthumb for performance issues and i
really like this, but right now i have to use phpthumb to get the
resizing to work as expected.

For now im back to phpthumb_old (as shown in your wiki), but now when
i upload a picture it has the wrong permissions (chmod600) and
therefore it cant be viewed (browser gives a 403 error).


Hope you can help me with this. I'd really like to get rid of
phpthumb, but right now its not possible.

Thanks,

Andi

volderette

unread,
Sep 15, 2010, 4:02:13 AM9/15/10
to Magic Fields
Im using version 1.4.1 right now.

brando...@gmail.com

unread,
Sep 15, 2010, 11:00:44 PM9/15/10
to Magic Fields
I was in the same situation, I didn't like how the new way images were
either being cropped or stretched. and i couldn't get it to function
like before. i didn't want to re-add phpthumb either. in the magic
fields plugin, there is a file "MF_thumb.php". the new images sizing
is mostly in here it looks like. it also looks like they based much
of the code on some internal WP image_resize functions. but not 100%,
if you replace line 118 to line 174 of MF_thumb.php with this code (is
from the WP internal resize function), you might get the results you
are looking. it works for me...

//new code (borrowed from wp)

// 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 );
}


brandon

Hunk

unread,
Sep 15, 2010, 11:58:31 PM9/15/10
to Magic Fields
add phpthumb support (phpthumb_old) and use get_image_p and
gen_image_p

On Sep 15, 10:00 pm, "brandon.s...@gmail.com" <brandon.s...@gmail.com>
wrote:

volderette

unread,
Sep 17, 2010, 5:00:38 AM9/17/10
to Magic Fields
Thanks Brandon, i will try that.

Regarding phpthumb_old: Im using it right now, but i changes all the
permissions to chmod 600 so i cant view it in the browser.

volderette

unread,
Sep 17, 2010, 5:13:00 AM9/17/10
to Magic Fields
Changing the code in MF_thumbs.php works just fine. Thanks a lot!

@Hunk: Just curious: Is there a reason why you using a different code
there?
Reply all
Reply to author
Forward
0 new messages