CC-3092: Station Information: not able to upload logo
- Adding a return statement fixed it...I don't what was I thinking... - Some indention seems messed up, fixed it
This commit is contained in:
parent
72553a257d
commit
8766cade49
1 changed files with 24 additions and 24 deletions
|
@ -1,14 +1,13 @@
|
|||
<?php
|
||||
|
||||
class Zend_Filter_ImageSize implements Zend_Filter_Interface {
|
||||
|
||||
public function filter($value) {
|
||||
if(!file_exists($value)) {
|
||||
if (!file_exists($value)) {
|
||||
throw new Zend_Filter_Exception('Image does not exist: ' . $value);
|
||||
}
|
||||
|
||||
$image = imageCreateFromString(file_get_contents($value));
|
||||
if(false === $image) {
|
||||
if (false === $image) {
|
||||
throw new Zend_Filter_Exception('Can\'t load image: ' . $value);
|
||||
}
|
||||
|
||||
|
@ -17,11 +16,9 @@ class Zend_Filter_ImageSize implements Zend_Filter_Interface {
|
|||
$origWidth = imagesx($image);
|
||||
$origHeight = imagesy($image);
|
||||
$ratio = max($origWidth, $origHeight) / 600;
|
||||
if($ratio < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// create a scaled down image
|
||||
if ($ratio > 1) {
|
||||
// img too big! create a scaled down image
|
||||
$newWidth = round($origWidth / $ratio);
|
||||
$newHeight = round($origHeight / $ratio);
|
||||
$resized = imagecreatetruecolor($newWidth, $newHeight);
|
||||
|
@ -29,14 +26,17 @@ class Zend_Filter_ImageSize implements Zend_Filter_Interface {
|
|||
|
||||
// determine type and store to disk
|
||||
$explodeResult = explode(".", $value);
|
||||
$type = $explodeResult[count($explodeResult) - 1];
|
||||
$type = strtolower($explodeResult[count($explodeResult) - 1]);
|
||||
$writeFunc = 'image' . $type;
|
||||
if($type == 'jpeg' || $type == 'jpg') {
|
||||
if ($type == 'jpeg' || $type == 'jpg') {
|
||||
imagejpeg($resized, $value, 100);
|
||||
} else {
|
||||
$writeFunc($resized, $value);
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue