Skip to content

Instantly share code, notes, and snippets.

@westonruter
Created February 10, 2010 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/300864 to your computer and use it in GitHub Desktop.
Save westonruter/300864 to your computer and use it in GitHub Desktop.
A patch to fix a “Scale to Fit” issue in the Shopp WordPress plugin
Index: core/model/Image.php
===================================================================
--- core/model/Image.php (revision 99)
+++ core/model/Image.php (revision 100)
@@ -72,16 +72,14 @@
if($this->src->height*$scale > $height){ // Now scale by height if it would end up too tall
$scale *= $height / ($this->src->height*$scale);
}
- $this->Processed->width = $width;
- $this->Processed->height = ceil($this->src->height * $scale);
} else { // Scale to height
$scale = $height / $this->src->height;
if($this->src->width*$scale > $width){ // Now scale by width if it would end up too wide
$scale *= $width / ($this->src->width*$scale);
}
- $this->Processed->height = ceil($this->src->height * $scale);
- $this->Processed->width = ceil($this->src->width * $scale);
}
+ $this->Processed->height = ceil($this->src->height * $scale);
+ $this->Processed->width = ceil($this->src->width * $scale);
$this->Processed->image = ImageCreateTrueColor($this->Processed->width,$this->Processed->height);
ImageCopyResampled($this->Processed->image, $this->src->image,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment