We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9353
    • 4 Posts
    We had a bit of trouble with the max_pic_size when defining the width and height in the parameter, eg: 600x480. The problem was it wasn’t resizing portrait style images who’s height was larger then the defined max and where the width was smaller than the max width defined. Ie: images would only resize if their width was wider than the max width, and completely ignore the height. We only noticed it when using smoothgallery as it doesn’t display the overflow.

    I jumped into the maxigallery class file: /assets/snippets/maxigallery/maxigallery.class.inc.php and edited the resize check guard for the normal image:
    Around line #442. It splits the max pic size parameter into an array and uses them to check against the images sizes..
    		$sizes = split('x', $this->mgconfig['max_pic_size']);	
    		if($this->mgconfig['max_pic_size']>0 && ($imagesize[0]>$sizes[0] || $imagesize[1]>$sizes[1])) {
    			$this->createthumb($name,$type,$this->path_to_gal,"");
    		}else if($this->mgconfig['pic_use_watermark'] || $this->mgconfig['pic_use_dropshadow'] || $this->mgconfig['pic_use_imagemask']){
    			//if max image size is not reached, but the image needs some changing to be done
    			$this->createthumb($name,$type,$this->path_to_gal,"",false);
    		}


    Seems to work fine for us smiley hope this helps someone else too.
      • 3749
      • 24,544 Posts
      Good catch. Thanks for the contribution. smiley
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 7923
        • 4,213 Posts
        Yes thanks, I’ll fix it for v0.6 final version.


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 26931
          • 2,314 Posts
          Hi fabilo,

          i tried your modification, unfortunately it didn’t get it to work, probably because i changed the wrong parts. could you be so kind and post the whole part of the maxigallery.class.inc that needs to be replacen?

          regards, j
            • 31906
            • 26 Posts
            Thanks! Really helpful wink
              • 25132
              • 129 Posts
              Great. Working for me smiley

              For those who are unsure where to place this, I changed the entire //create normal bit to:

              //create normal 		
              		$sizes = split('x', $this->mgconfig['max_pic_size']);	
              		if($this->mgconfig['max_pic_size']>0 && ($imagesize[0]>$sizes[0] || $imagesize[1]>$sizes[1])) {
              			$this->createthumb($name,$type,$this->path_to_gal,"");
              		}else if($this->mgconfig['pic_use_watermark'] || $this->mgconfig['pic_use_dropshadow'] || $this->mgconfig['pic_use_imagemask']){
              			//if max image size is not reached, but the image needs some changing to be done
              			$this->createthumb($name,$type,$this->path_to_gal,"",false);
              		}
              		if($modx->getLoginUserID()!="" && $modx->getLoginUserType()=='web'){ //if web user is posting picture, put owner id
              			$rs1=$modx->db->query("INSERT INTO " . $this->pics_tbl . "(id, gal_id, filename, title, date, own_id) VALUES(NULL,'" . $this->pageinfo['id'] . "','" . $name . "',''," . $pic_date . ",'".$modx->getLoginUserID()."')");
              		}else{
              			$rs1=$modx->db->query("INSERT INTO " . $this->pics_tbl . "(id, gal_id, filename, title, date) VALUES(NULL,'" . $this->pageinfo['id'] . "','" . $name . "',''," . $pic_date . ")");
              		}