Im using the indexhibit cms. This cms comes with some nice features such as image resizing on upload..the only problem is that it resizes the image by width and I want to switch it so it resizes the images by height.
here is the code, I have tried switching the x and y and the height (h) and width (w) but it didnt work please help!!
PHP Code:
<?php if (!defined('SITE')) exit('No direct script access allowed');
/**
* Media class
*
* Resizes and thumbnails images
*
* @version 1.0
* @author Vaska
*/
class Media
{
var $image;
var $path;
var $filename;
var $quality;
var $filemime;
var $maxsize;
var $thumbsize;
var $sizelimit;
var $size = array();
var $new_size = array();
var $makethumb = FALSE;
var $final_size = array();
var $out_size = array();
var $uploads = array();
var $sys_thumb = 100;
var $offset = array();
var $sys_size = array();
var $type;
var $input_image;
var $upload_max_size;
var $file_size;
var $tRed;
var $tBlue;
var $tGreen;
var $tFlag = FALSE;
/**
* Returns allowed uploads (filetypes from config.php) array and max size
*
* @param void
* @return mixed
*/
function Media()
{
global $uploads;
$this->uploads = $uploads;
$this->upload_max_size();
}
// first image
$this->upload_image($this->maxsize);
$this->file_size();
// system thumbnail
$this->sys_thumb($this->sys_thumb);
// we'll need to distinguish this for only images
if (($this->makethumb == TRUE) && (in_array($this->filemime, $this->allowThumbs())))
{
$this->upload_image($this->thumbsize, TRUE);
}
imagedestroy($this->input_image);
}
/**
* Deals with the bits
* Oh. So. Messy. ;)
*
* @param integer $maxwidth
* @param boolean $thumb
* @return integer
*/
function upload_image($maxwidth, $thumb=FALSE)
{
if (($maxwidth != 9999) || ($thumb == TRUE))
{
// get the new sizes
$this->resizing($maxwidth);
// if we have transparency in the image
// it sucks that PHP auto sets background to black!!!!!!!
if ($this->tFlag == TRUE)
{
imagecolortransparent($output_image, imagecolorallocate($output_image,
$this->tRed, $this->tGreen, $this->tBlue));
}
// png special handling rules
if ($this->filemime == 'png')
{
// [url]http://be.php.net/manual/en/function.imagesavealpha.php[/url]
imagealphablending($output_image, false);
imagesavealpha($output_image, true);
}
// if we have transparency in the image
// it sucks that PHP auto sets background to black!!!!!!!
if ($this->tFlag == TRUE)
{
imagecolortransparent($output_image, imagecolorallocate($output_image,
$this->tRed, $this->tGreen, $this->tBlue));
}
// png special handling rules
if ($this->filemime == 'png')
{
// [url]http://be.php.net/manual/en/function.imagesavealpha.php[/url]
imagealphablending($output_image, false);
imagesavealpha($output_image, true);
}
/**
* Returns new file name based upon exiting files to prevent name collisions
*
* @param string $filename
* @return string
*/
function checkName($filename)
{
static $v = 1;
if (file_exists($this->path . '/' . $filename . $this->type))
{
// remove the previous version number
$filename = preg_replace('/_v[0-9]{1,3}$/i', '', $filename);
$v++;
$filename = $filename . '_v' . $v;
$filename = $this->checkName($filename);
}
else
{
$v = 1;
return $filename;
}
return $filename;
}
}
?>
Last edited by Fou-Lu; 04-01-2010 at 04:49 PM..
Reason: Needs some PHP tags here