feat: change image crop algorythm for product view page

This commit is contained in:
2025-12-23 17:32:37 +03:00
parent 0ee3b7d091
commit 262f529290
2 changed files with 8 additions and 6 deletions

View File

@@ -7,7 +7,7 @@ services:
- "./scripts:/scripts" - "./scripts:/scripts"
- "./module:/module" - "./module:/module"
- "./build:/build" - "./build:/build"
- "/Users/nikitakiselev/code/italy-moda/image/catalog:/web/upload/image/catalog" # - "/Users/nikitakiselev/code/italy-moda/image/catalog:/web/upload/image/catalog"
ports: ports:
- "8000:80" - "8000:80"
restart: always restart: always

View File

@@ -430,8 +430,11 @@ class ProductsService
public function getProductImages(int $productId): array public function getProductImages(int $productId): array
{ {
$imageThumbWidth = 500; $aspectRatio = $this->settings->get('app.image_aspect_ratio', '1:1');
$imageThumbHeight = 500; $cropAlgorithm = $this->settings->get('app.image_crop_algorithm', 'cover');
[$imageWidth, $imageHeight] = ImageUtils::aspectRatioToSize($aspectRatio);
$imageFullWidth = 1000; $imageFullWidth = 1000;
$imageFullHeight = 1000; $imageFullHeight = 1000;
@@ -456,9 +459,8 @@ class ProductsService
try { try {
[$width, $height] = $this->image->make($imagePath)->getRealSize(); [$width, $height] = $this->image->make($imagePath)->getRealSize();
$images[] = [ $images[] = [
'thumbnailURL' => $this->image 'thumbnailURL' => $this->image->make($imagePath)
->make($imagePath) ->crop($cropAlgorithm, $imageWidth, $imageHeight)
->contain($imageThumbWidth, $imageThumbHeight)
->url(), ->url(),
'largeURL' => $this->image->make($imagePath)->resize($imageFullWidth, $imageFullHeight)->url(), 'largeURL' => $this->image->make($imagePath)->resize($imageFullWidth, $imageFullHeight)->url(),
'width' => $width, 'width' => $width,