WordPress.org

Ready to get started?Download WordPress

Forums

NextGEN Gallery
[resolved] plugin generates wrong thumbnail size (21 posts)

  1. jimmyjjames
    Member
    Posted 4 years ago #

    Hello,

    i am using wordpress 3.0 and the NextGEN Gallery 1.5.5 - plugin. for some reasons this plugin generates wrong thumbnail size. for example: in the options i set "width x height" to "150 x 105" and ckeck the option "ignore image propotions".

    then i upload an image with a dimension of 900x624 and the plugin generates a thumbnail with a dimension of 147x105. but it should be 150x105.

    has someone a solution, or is a bugfix comming?

    thanx in advance for help,
    alekz

    http://wordpress.org/extend/plugins/nextgen-gallery/

  2. jimmyjjames
    Member
    Posted 4 years ago #

    hi,
    its me again.

    i looked into the source (lib/gd.thumbnail.inc.php). following things i have noticed:

    1. the "resize" function is called, but perhaps "resizeFix" should be called!?
    2. param $maxWidth is not set (but should be 150)
    3. calcHeight function is called and calculates for the width proportionally the value 147 (instead the new imagesize should be calculated to 150x107 and afterwards be cropped to 150x105)

    can someone approve this false behaviour?
    does someone know, why the param $maxWidth of the "resize"-function is not set?
    is someone sure, if the "resize" or "resizeFix" function should be called.

    this excellent plug-in is unfortunately useless with this bug.

    alekz

  3. jimmyjjames
    Member
    Posted 4 years ago #

    Hi,

    so my solution is:

    in the file functions.php in line 272 i replace

    if ($ngg->options['thumbfix'])  {
    	// check for portrait format
    
    	if ($thumb->currentDimensions['height'] < $thumb->currentDimensions['width']) {
    
    		// first resize to the wanted width
    		$thumb->resize($ngg->options['thumbwidth'], 0);
    		// get optimal y startpos
    		$ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2;
    		$thumb->crop(0, $ypos, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
    	} else {
    
    		// first resize to the wanted height
    		$thumb->resize(0, $ngg->options['thumbheight']);
    		// get optimal x startpos
    		$xpos = ($thumb->currentDimensions['width'] - $ngg->options['thumbwidth']) / 2;
    		$thumb->crop($xpos, 0, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
    	}
    //this create a thumbnail but keep ratio settings
    } else {
    	$thumb->resize($ngg->options['thumbwidth'],$ngg->options['thumbheight']);
    }

    with

    if ($ngg->options['thumbfix'])  {
    	// check for portrait format
    
    	// first resize to the wanted width
    	$thumb->resize($ngg->options['thumbwidth'], 0);
    	// get optimal y startpos
    	$ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2;
    	$thumb->crop(0, $ypos, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);	
    
    	//this create a thumbnail but keep ratio settings
    } else {
    	$thumb->resize($ngg->options['thumbwidth'],$ngg->options['thumbheight']);
    }

    and it seems to work.

    maybe alex rabe could verify this und implement this bugfix into the plugin.

    alekz

  4. swam2222
    Member
    Posted 4 years ago #

    Hi Jimmy,

    Which file does this replacement code go into?

    My themes function.php doesn't go up to line 272 and doesn't contain any of the code which you replace.

    thanks

    Sam

  5. Paulio51
    Member
    Posted 4 years ago #

    I believe he meant wp-content\plugins\nextgen-gallery\admin\functions.php

    Paul

  6. swam2222
    Member
    Posted 4 years ago #

    Hi Paulio,

    Thanks for that.

    cheers

    Sam

  7. jimmyjjames
    Member
    Posted 4 years ago #

    Sorry for the late reply! Don't we get mails, if a reply is sent on a thread in this forum?

    yes i meant indeed the wp-content\plugins\nextgen-gallery\admin\functions.php file.

    works it for you too?

    jimmy

  8. jimmyjjames
    Member
    Posted 4 years ago #

    Ok,
    hi again. The last solution wasn't right. I recognized it just now. But here is the final solution, and for me and the images i have it works.

    so again go to the wp-content\plugins\nextgen-gallery\admin\functions.php, line 272 and replace

    if ($ngg->options['thumbfix'])  {
    	// check for portrait format
    
    	if ($thumb->currentDimensions['height'] < $thumb->currentDimensions['width']) {
    
    		// first resize to the wanted width
    		$thumb->resize($ngg->options['thumbwidth'], 0);
    		// get optimal y startpos
    		$ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2;
    		$thumb->crop(0, $ypos, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
    	} else {
    
    		// first resize to the wanted height
    		$thumb->resize(0, $ngg->options['thumbheight']);
    		// get optimal x startpos
    		$xpos = ($thumb->currentDimensions['width'] - $ngg->options['thumbwidth']) / 2;
    		$thumb->crop($xpos, 0, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
    	}
    //this create a thumbnail but keep ratio settings
    } else {
    	$thumb->resize($ngg->options['thumbwidth'],$ngg->options['thumbheight']);
    }

    with

    if ($ngg->options['thumbfix'])  {
    	// check for portrait format
    
    	$wratio = $ngg->options['thumbwidth'] / $thumb->currentDimensions['width'];
    	$hratio = $ngg->options['thumbheight'] / $thumb->currentDimensions['height'];
    
    	if ($wratio > $hratio) {
    
    		// first resize to the wanted width
    		$thumb->resize($ngg->options['thumbwidth'], 0);
    		// get optimal y startpos
    		$ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2;
    		$thumb->crop(0, $ypos, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
    	} else {
    
    		// first resize to the wanted height
    		$thumb->resize(0, $ngg->options['thumbheight']);
    		// get optimal x startpos
    		$xpos = ($thumb->currentDimensions['width'] - $ngg->options['thumbwidth']) / 2;
    		$thumb->crop($xpos, 0, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
    	}
    //this create a thumbnail but keep ratio settings
    } else {
    	$thumb->resize($ngg->options['thumbwidth'],$ngg->options['thumbheight']);
    }

    i hope it works for you too, and it would be nice if this bugfix would be implemented in the original plugin, so we dont have to reimplement it everytime a new version of the plug in comes out.

    cu,
    jimmy aka alekz

  9. srichand
    Member
    Posted 4 years ago #

    Hi,

    Thanks for ur valuable posts......
    keep on the good work

  10. srichand
    Member
    Posted 4 years ago #

    hi,

    why lightbox effect is not working for me......???
    any suggestions!!!!!!!!

  11. thedrewseum
    Member
    Posted 4 years ago #

    Unfortunately this fix didn't work for me :/ Photos with a size ratio that is slightly 'off' still generate smaller thumbnails. Hopefully this will be fixed soon, it's the only problem I have with this amazing gallery plug-in.

  12. jimmyjjames
    Member
    Posted 4 years ago #

    can u tell me the exact size of your photos, so i can test it?

  13. tjsherrill
    Member
    Posted 4 years ago #

    Just to give a bump to this post. JimmyJames solution worked for me. I replaced the lines and things are working better. Cropping is delivering better results.

    thanks

  14. thedrewseum
    Member
    Posted 4 years ago #

    can u tell me the exact size of your photos, so i can test it?

    Jimmy, my thumbs are 80x100. The photos themselves are a variety of sizes.

  15. jimmyjjames
    Member
    Posted 4 years ago #

    hi thedrewseum,

    i can't reproduce the problem with the target thumbnail size of 80x100 pixels. have you checked the option "Set fix dimension"?

    I have just committed a patch to googlecode for this problem. Hopefully it will be applied in the final version 1.6.0.

    alekz

  16. jimmyjjames
    Member
    Posted 4 years ago #

  17. jimmyjjames
    Member
    Posted 4 years ago #

    bugfix is now in implemented in the plugin (fixed in r789):
    http://code.google.com/p/nextgen-gallery/issues/detail?id=308

  18. thedrewseum
    Member
    Posted 4 years ago #

    HALLELUJAH! It worked! I'm so grateful for this fix, thanks to everyone who got it working!

  19. kikaweb
    Member
    Posted 4 years ago #

    Hello! I'm using the latest version of the plug-in and WP 3.0.3 and I'm having the same problem: images inserted in the article and in the galleries are resized correctly, while the featured thumbnails aren't (the image is cropped to 940x198px). The problems seem to be with images bigger than 150x150 px, so it has something to do with cropping.
    Is there any solution?
    Thanks

  20. kikaweb
    Member
    Posted 4 years ago #

    After spending a whole day troubleshooting I found out that my problem was not related to NGG, but to the theme itself.
    For all those who might have the same problem: in my case the 'featured image' size was set in my theme's function.php file (it's a theme based on the original Twenty Ten), this thread pointed me to the right direction: http://wordpress.org/support/topic/wordpress-3-featured-image-linking-to-full-size-image-not-actual-thumbnail?replies=5

  21. standardspace
    Member
    Posted 3 years ago #

    Thanks Jimmy,
    I spent many hours in vain trying to fix this.
    You're a star.

    Patrick

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.