diff --git a/resources/config/sharp.php b/resources/config/sharp.php index 74409a3..9f167e0 100644 --- a/resources/config/sharp.php +++ b/resources/config/sharp.php @@ -5,8 +5,12 @@ "upload_storage_disk" => "local", "upload_storage_base_path" => "data", + "thumbnail_in_storage" => false, "thumbnail_relative_path" => "sharp/thumbnails", "upload_tmp_base_path" => "tmp/sharp", + "file_queue_name" => null, + + "user_login_field_name" => "login", "categories" => [] ]; \ No newline at end of file diff --git a/src/helpers/sharp_helper.php b/src/helpers/sharp_helper.php index 9ca4493..dd3a6ad 100644 --- a/src/helpers/sharp_helper.php +++ b/src/helpers/sharp_helper.php @@ -25,8 +25,6 @@ function sharp_thumbnail($source, $w, $h, $params = [], $relativeFolder=null, $i $source = config("sharp.upload_storage_base_path") . "/" . $source; } - $thumbnailPath = config("sharp.thumbnail_relative_path"); - $sizeMin = isset($params["size_min"]) && $params["size_min"]; if ($w == 0) { @@ -36,8 +34,20 @@ function sharp_thumbnail($source, $w, $h, $params = [], $relativeFolder=null, $i $h = null; } - $thumbName = "$thumbnailPath/$relativeFolder/$w-$h" . ($sizeMin ? "_min" : "") . "/" . basename($source); - $thumbFile = public_path($thumbName); + $thumbName = "$relativeFolder/$w-$h" + . ($sizeMin ? "_min" : "") + . "/" . basename($source); + + $thumbnailPath = config("sharp.thumbnail_relative_path"); + + if(config("sharp.thumbnail_in_storage", false)) { + $thumbFile = storage_path( + "app/public/$thumbnailPath/".config('sharp.upload_storage_base_path')."/$thumbName" + ); + + } else { + $thumbFile = public_path("$thumbnailPath/$thumbName"); + } if (!file_exists($thumbFile)) { @@ -74,7 +84,11 @@ function sharp_thumbnail($source, $w, $h, $params = [], $relativeFolder=null, $i } } - return url($thumbName); + if(config("sharp.thumbnail_in_storage", false)) { + return url("storage/$thumbnailPath/".config('sharp.upload_storage_base_path')."/$thumbName"); + } + + return url("$thumbnailPath/$thumbName"); } /** diff --git a/version.txt b/version.txt index f1d82e6..3e1f84b 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -3.1.26 \ No newline at end of file +3.1.27 \ No newline at end of file