FEATURE: make thumbnails from uploaded image

This commit is contained in:
Michal Kváček
2016-09-26 15:21:30 +02:00
parent 6868af609f
commit cd28625309
11 changed files with 262 additions and 12 deletions
+1 -6
View File
@@ -17,12 +17,7 @@ class FileManager
switch ($type) {
case 'image':
// try to check if file have thumbnail
if (file_exists(config('app.thumbnail_url') . '/' . $file->filename)) {
$url = config('app.thumbnail_url') . '/' . $file->filename;
} else {
$url = config('app.upload_url') . '/' . $file->filename;
}
$url = Template::thumbnail($file->filename);
return '<img src="' . $url . '" alt="' . $file->description . '" />';
break;
+12
View File
@@ -61,6 +61,18 @@ class Template
return config('app.upload_url') . '/' . $filename;
}
public static function thumbnail($filename)
{
// try to check if file have thumbnail
if (file_exists(config('app.thumbnail_path') . '/' . $filename)) {
$url = config('app.thumbnail_url') . '/' . $filename;
} else {
$url = self::upload($filename);
}
return $url;
}
/**
* Get path to given asset
*