diff options
| author | Frederic Guillot <fred@kanboard.net> | 2016-03-26 14:43:41 -0400 |
|---|---|---|
| committer | Frederic Guillot <fred@kanboard.net> | 2016-03-26 14:43:41 -0400 |
| commit | 820c929ab38273c80d0930e2e6140dd7676ba4df (patch) | |
| tree | 3944047e41d14077f7e5e8c0d50856b360a22567 /app/Model/File.php | |
| parent | e71f37238c82f01cd02d6d7343b42328d9603d14 (diff) | |
Added avatar image upload
Diffstat (limited to 'app/Model/File.php')
| -rw-r--r-- | app/Model/File.php | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/app/Model/File.php b/app/Model/File.php index 03ea691d..5e77060c 100644 --- a/app/Model/File.php +++ b/app/Model/File.php @@ -3,6 +3,7 @@ namespace Kanboard\Model; use Exception; +use Kanboard\Core\Thumbnail; use Kanboard\Event\FileEvent; use Kanboard\Core\Tool; use Kanboard\Core\ObjectStorage\ObjectStorageException; @@ -315,15 +316,15 @@ abstract class File extends Base */ public function generateThumbnailFromData($destination_filename, &$data) { - $temp_filename = tempnam(sys_get_temp_dir(), 'datafile'); + $blob = Thumbnail::createFromString($data) + ->resize() + ->toString(); - file_put_contents($temp_filename, $data); - $this->generateThumbnailFromFile($temp_filename, $destination_filename); - unlink($temp_filename); + $this->objectStorage->put($this->getThumbnailPath($destination_filename), $blob); } /** - * Generate thumbnail from a blob + * Generate thumbnail from a local file * * @access public * @param string $uploaded_filename @@ -331,8 +332,10 @@ abstract class File extends Base */ public function generateThumbnailFromFile($uploaded_filename, $destination_filename) { - $thumbnail_filename = tempnam(sys_get_temp_dir(), 'thumbnail'); - Tool::generateThumbnail($uploaded_filename, $thumbnail_filename); - $this->objectStorage->moveFile($thumbnail_filename, $this->getThumbnailPath($destination_filename)); + $blob = Thumbnail::createFromFile($uploaded_filename) + ->resize() + ->toString(); + + $this->objectStorage->put($this->getThumbnailPath($destination_filename), $blob); } } |
