feat: change image crop algorythm for product view page
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user