From 323bce8daa5efbfca8de2d95366a97dace9cc974 Mon Sep 17 00:00:00 2001 From: ph0enix Date: Wed, 12 Sep 2012 02:07:37 +0400 Subject: [PATCH] Thumbnail background fix, code formatting --- php/elFinderVolumeDriver.class.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/php/elFinderVolumeDriver.class.php b/php/elFinderVolumeDriver.class.php index 441ed71e8e..65e57ee44c 100644 --- a/php/elFinderVolumeDriver.class.php +++ b/php/elFinderVolumeDriver.class.php @@ -2706,18 +2706,17 @@ protected function createTmb($path, $stat) { return false; } - /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ - if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); + /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ + if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); + } else { - } else { - - if ($this->options['tmbCrop']) { + if ($this->options['tmbCrop']) { - /* Resize and crop if image bigger than thumbnail */ - if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { - $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); - } + /* Resize and crop if image bigger than thumbnail */ + if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { + $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); + } if (($s = getimagesize($tmb)) != false) { $x = $s[0] > $tmbSize ? intval(($s[0] - $tmbSize)/2) : 0; @@ -2725,12 +2724,13 @@ protected function createTmb($path, $stat) { $result = $this->imgCrop($tmb, $tmbSize, $tmbSize, $x, $y, 'png'); } - } else { - $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, $this->imgLib, 'png'); - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); - } + } else { + $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, $this->imgLib, 'png'); + } + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); } + if (!$result) { unlink($tmb); return false;