-
The Previous Posting
« Utilizing GZip with... -
The Next Posting
Disable Microsoft Software... »
Force Nextgen Gallery To Crop Thumbnails From The Top Of The Image... **Updated**

In our original post, we simply deleted a line to change the starting position of NextGEN’s thumbnail crop. With the most recent version of NextGEN Gallery,1.4.3 as of this postings date, this was generating errors. So we dug around in the code a bit, and here’s our fix.
First locate the code below. Located currently at line #270.
270 271 272
// get optimal y startpos $ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2; $thumb->crop(0, $ypos, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
And change the code to the following.
270 271 272
// get optimal y startpos $ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2; $thumb->crop(0, null, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
You’ll notice that all we did we did was change the starting position of the crop, by changing “$ypos” to “null”. And wallah, thumbnail crops start from the top.
In turn, you could also crop the images from the bottom by changing the code from.
270 271 272
// get optimal y startpos $ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2; $thumb->crop(0, $ypos, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
To...
270 271 272
// get optimal y startpos $ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 1; $thumb->crop(0, $ypos, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
The change here is the math integer. We changed / 2, or divide by two, to / 1 or divide by one. If we had an image of 700px, the original coding would tell the crop to originate from the center, or half of 700. We’ve changed that to 1, telling it to originate the crop from the bottom or 700.
Hope this helps someone. Let use know by leaving a comment.
Our original post.........
We recently finished a custom themed photo gallery for a client utilizing the NextGen Gallery plugin. NextGen is an amazingly well rounded plugin with loads of options and configurations. One major complaint our client had about NextGen was that the thumbnails were generated in a way that was chopping the top off the image. A large majority of his images are portrait shaped, taller than wide, and required that the top be visible in the thumbnail image.
After searching through the WordPress and NextGen forums, we we’re still coming up empty handed. So we started digging around in the code. We eventually came to the following line. The following code tells Nextgen to center the thumbnail crop at half the Y Position, height divided by two, or the center of the picture vertically. So we just deleted it, and now the crop starts from the top of the picture. Problem fixed. Now our client doesn’t have to manually resize each thumbnail, making him a happy client.
location: [your plugin folder]/nextgen-gallery/admin/functions.php
Line# 289
289
$ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2;
The most recent Google source code shows this at line #288. So be sure to pay attention to which line you delete.
This works absolutely fine. Is there any way we can edit the code to resize full images to thumbnail like TimThumb script does instead of cropping from top or bottom.
Brilliant, and that fixed our issue, thanks for posting this up guys!
cheers
K&B