diff --git a/controllers/FilesApiController.php b/controllers/FilesApiController.php
index fb7f619b..29c4b98f 100644
--- a/controllers/FilesApiController.php
+++ b/controllers/FilesApiController.php
@@ -59,13 +59,13 @@ class FilesApiController extends BaseApiController
if ($forceServeAs == FilesService::FILE_SERVE_TYPE_PICTURE)
{
- $bestFitHeight = 999999;
+ $bestFitHeight = null;
if (isset($request->getQueryParams()['best_fit_height']) && !empty($request->getQueryParams()['best_fit_height']) && is_numeric($request->getQueryParams()['best_fit_height']))
{
$bestFitHeight = $request->getQueryParams()['best_fit_height'];
}
- $bestFitWidth = 999999;
+ $bestFitWidth = null;
if (isset($request->getQueryParams()['best_fit_width']) && !empty($request->getQueryParams()['best_fit_width']) && is_numeric($request->getQueryParams()['best_fit_width']))
{
$bestFitWidth = $request->getQueryParams()['best_fit_width'];
diff --git a/controllers/RecipesController.php b/controllers/RecipesController.php
index be309aaf..61838c6d 100644
--- a/controllers/RecipesController.php
+++ b/controllers/RecipesController.php
@@ -63,7 +63,7 @@ class RecipesController extends BaseController
'selectedRecipe' => $selectedRecipe,
'selectedRecipePositionsResolved' => $selectedRecipePositionsResolved,
'products' => $this->Database->products(),
- 'quantityunits' => $this->Database->quantity_units(),
+ 'quantityUnits' => $this->Database->quantity_units(),
'selectedRecipeSubRecipes' => $selectedRecipeSubRecipes,
'selectedRecipeSubRecipesPositions' => $selectedRecipeSubRecipesPositions,
'includedRecipeIdsAbsolute' => $includedRecipeIdsAbsolute,
diff --git a/package.json b/package.json
index 27cf9823..c8dd94ec 100644
--- a/package.json
+++ b/package.json
@@ -31,6 +31,7 @@
"tempusdominus-bootstrap-4": "https://github.com/berrnd/tempusdominus-bootstrap-4.git#master",
"timeago": "^1.6.7",
"toastr": "^2.1.4",
- "bootstrap-select": "^1.13.10"
+ "bootstrap-select": "^1.13.10",
+ "jquery-lazy": "^1.7.10"
}
}
diff --git a/public/js/grocy.js b/public/js/grocy.js
index 03fd0bc3..b2f13fff 100644
--- a/public/js/grocy.js
+++ b/public/js/grocy.js
@@ -526,3 +526,12 @@ $("textarea.wysiwyg-editor").summernote({
minHeight: "300px",
lang: __t("summernote_locale")
});
+
+function LoadImagesLazy()
+{
+ $(".lazy").Lazy({
+ enableThrottle: true,
+ throttle: 500
+ });
+}
+LoadImagesLazy();
diff --git a/public/viewjs/components/productcard.js b/public/viewjs/components/productcard.js
index 78f2cf8e..111f2ca4 100644
--- a/public/viewjs/components/productcard.js
+++ b/public/viewjs/components/productcard.js
@@ -82,7 +82,7 @@ Grocy.Components.ProductCard.Refresh = function(productId)
{
$("#productcard-no-product-picture").addClass("d-none");
$("#productcard-product-picture").removeClass("d-none");
- $("#productcard-product-picture").attr("src", U('/api/files/productpictures/' + btoa(productDetails.product.picture_file_name) + '?force_serve_as=picture&best_fit_height=400&best_fit_width=400'));
+ $("#productcard-product-picture").attr("src", U('/api/files/productpictures/' + btoa(productDetails.product.picture_file_name) + '?force_serve_as=picture&best_fit_width=400'));
}
else
{
diff --git a/public/viewjs/mealplan.js b/public/viewjs/mealplan.js
index 463ddbbf..bb78a02c 100644
--- a/public/viewjs/mealplan.js
+++ b/public/viewjs/mealplan.js
@@ -103,12 +103,13 @@ var calendar = $("#calendar").fullCalendar({
if (recipe.picture_file_name && !recipe.picture_file_name.isEmpty())
{
- element.html(element.html() + '')
+ element.html(element.html() + '
')
}
},
"eventAfterAllRender": function(view)
{
RefreshLocaleNumberDisplay();
+ LoadImagesLazy();
if (GetUriParam("week") !== undefined)
{
diff --git a/services/FilesService.php b/services/FilesService.php
index c1824b2f..47ed79a4 100644
--- a/services/FilesService.php
+++ b/services/FilesService.php
@@ -33,13 +33,13 @@ class FilesService extends BaseService
return $groupFolderPath . '/' . $fileName;
}
- public function DownscaleImage($group, $fileName, $bestFitHeight, $bestFitWidth)
+ public function DownscaleImage($group, $fileName, $bestFitHeight = null, $bestFitWidth = null)
{
$filePath = $this->GetFilePath($group, $fileName);
$fileNameWithoutExtension = pathinfo($filePath, PATHINFO_FILENAME);
$fileExtension = pathinfo($filePath, PATHINFO_EXTENSION);
- $fileNameDownscaled = $fileNameWithoutExtension . '__downscaledto' . $bestFitHeight . 'x' . $bestFitWidth . '.' . $fileExtension;
+ $fileNameDownscaled = $fileNameWithoutExtension . '__downscaledto' . ($bestFitHeight ? $bestFitHeight : 'auto') . 'x' . ($bestFitWidth ? $bestFitWidth : 'auto') . '.' . $fileExtension;
$filePathDownscaled = $this->GetFilePath($group, $fileNameDownscaled);
try
@@ -47,7 +47,18 @@ class FilesService extends BaseService
if (!file_exists($filePathDownscaled))
{
$image = new ImageResize($filePath);
- $image->resizeToBestFit($bestFitHeight, $bestFitWidth);
+ if ($bestFitHeight !== null && $bestFitHeight !== null)
+ {
+ $image->resizeToBestFit($bestFitWidth, $bestFitHeight);
+ }
+ else if ($bestFitHeight !== null)
+ {
+ $image->resizeToHeight($bestFitHeight);
+ }
+ else if ($bestFitWidth !== null)
+ {
+ $image->resizeToWidth($bestFitWidth);
+ }
$image->save($filePathDownscaled);
}
}
diff --git a/views/components/productcard.blade.php b/views/components/productcard.blade.php
index edd0058d..fe98809e 100644
--- a/views/components/productcard.blade.php
+++ b/views/components/productcard.blade.php
@@ -28,7 +28,7 @@
{{ $__t('Spoil rate') }}:
{{ $__t('The current picture will be deleted when you save the product') }}
@else{{ $__t('No picture available') }}
diff --git a/views/recipeform.blade.php b/views/recipeform.blade.php index c12da217..bd1aabca 100644 --- a/views/recipeform.blade.php +++ b/views/recipeform.blade.php @@ -209,7 +209,7 @@ @if(!empty($recipe->picture_file_name)) -{{ $__t('The current picture will be deleted when you save the recipe') }}
@else{{ $__t('No picture available') }}
diff --git a/views/recipes.blade.php b/views/recipes.blade.php index a39dd86b..af59fbdc 100644 --- a/views/recipes.blade.php +++ b/views/recipes.blade.php @@ -102,7 +102,7 @@