summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Controller/File.php53
-rw-r--r--app/Template/file/show.php2
-rw-r--r--assets/css/app.css3
-rw-r--r--assets/css/src/task.css3
4 files changed, 40 insertions, 21 deletions
diff --git a/app/Controller/File.php b/app/Controller/File.php
index 3963e2d7..a27942e7 100644
--- a/app/Controller/File.php
+++ b/app/Controller/File.php
@@ -112,6 +112,7 @@ class File extends Base
$file = $this->file->getById($this->request->getIntegerParam('file_id'));
$width_param = $this->request->getIntegerParam('width');
$height_param = $this->request->getIntegerParam('height');
+ $resize_cut_param = $this->request->getIntegerParam('resize_cut');
$filename = FILES_DIR.$file['path'];
if ($file['task_id'] == $task['id'] && file_exists($filename)) {
@@ -119,22 +120,46 @@ class File extends Base
// Get new sizes
list($width, $height) = getimagesize($filename);
- if ($width_param == 0 && $height_param == 0) {
- $newwidth = 100;
- $newheight = 100;
- } elseif ($width_param > 0 && $height_param == 0) {
- $newwidth = $width_param;
- $newheight = floor($height * ($width_param / $width));
- } elseif ($width_param == 0 && $height_param > 0) {
- $newwidth = floor($width * ($height_param / $height));
- $newheight = $height_param;
+ if($resize_cut_param == 0){
+ //resize without cut
+ if ($width_param == 0 && $height_param == 0) {
+ $newwidth = 100;
+ $newheight = 100;
+ } elseif ($width_param > 0 && $height_param == 0) {
+ $newwidth = $width_param;
+ $newheight = floor($height * ($width_param / $width));
+ } elseif ($width_param == 0 && $height_param > 0) {
+ $newwidth = floor($width * ($height_param / $height));
+ $newheight = $height_param;
+ } else {
+ $newwidth = $width_param;
+ $newheight = $height_param;
+ }
+ $dest_y = 0;
+ $dest_x = 0;
+ $thumb = imagecreatetruecolor($newwidth, $newheight);
} else {
- $newwidth = $width_param;
- $newheight = $height_param;
+ // resize and cut
+ $ratio_img = $width / $height;
+ $ratio_param = $width_param / $height_param;
+
+ if($ratio_img < $ratio_param){
+ $newwidth = $width_param;
+ $newheight = floor($height * ($width_param / $width));
+
+ $dest_y = ( $newheight - $height_param ) / 2 * (-1);
+ $dest_x = 0;
+ }elseif($ratio_img > $ratio_param){
+ $newwidth = floor($width * ($height_param / $height));
+ $newheight = $height_param;
+
+ $dest_y = 0;
+ $dest_x = ( $newwidth - $width_param ) / 2;
+ }
+ $thumb = imagecreatetruecolor($width_param, $height_param);
}
- // Load
- $thumb = imagecreatetruecolor($newwidth, $newheight);
+ // Load
$extension = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
switch ($extension) {
@@ -154,7 +179,7 @@ class File extends Base
}
// Resize
- imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
+ imagecopyresampled($thumb, $source, $dest_x, $dest_y, 0, 0, $newwidth, $newheight, $width, $height);
$metadata = getimagesize($filename);
diff --git a/app/Template/file/show.php b/app/Template/file/show.php
index bfed94a5..66e1afd9 100644
--- a/app/Template/file/show.php
+++ b/app/Template/file/show.php
@@ -11,7 +11,7 @@
<li>
<?php if (function_exists('imagecreatetruecolor')): ?>
<div class="img_container">
- <img src="<?= $this->u('file', 'thumbnail', array('width' => 250, 'file_id' => $file['id'], 'project_id' => $task['project_id'], 'task_id' => $file['task_id'])) ?>" alt="<?= $this->e($file['name']) ?>"/>
+ <img src="<?= $this->u('file', 'thumbnail', array('width' => 250, 'height' => 100, 'resize_cut' => 1, 'file_id' => $file['id'], 'project_id' => $task['project_id'], 'task_id' => $file['task_id'])) ?>" alt="<?= $this->e($file['name']) ?>"/>
</div>
<?php endif ?>
<p>
diff --git a/assets/css/app.css b/assets/css/app.css
index e3797b1d..0c9276ba 100644
--- a/assets/css/app.css
+++ b/assets/css/app.css
@@ -1112,9 +1112,6 @@ span.task-board-date-overdue {
.task-show-image-actions {
margin-left: 5px;
}
-.task-show-images li .img_container:hover {
- height: 100%;
-}
.task-show-file-table {
width: auto;
}
diff --git a/assets/css/src/task.css b/assets/css/src/task.css
index 8d94945f..c57d8fc2 100644
--- a/assets/css/src/task.css
+++ b/assets/css/src/task.css
@@ -272,9 +272,6 @@ span.task-board-date-overdue {
.task-show-image-actions {
margin-left: 5px;
}
-.task-show-images li .img_container:hover {
- height: 100%;
-}
.task-show-file-table {
width: auto;
}