Skip to content

Commit

Permalink
[framework] handle image resizing by image proxy (#2924)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitek-rostislav authored Dec 7, 2023
2 parents 4c792d7 + 7a82dc7 commit cc6b51b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ services:
class: Shopsys\ReadModelBundle\Twig\ImageExtension
arguments:
$frontDesignImageUrlPrefix: '%shopsys.front_design_image_url_prefix%'
$isLazyLoadEnabled: '%shopsys.image.enable_lazy_load%'
18 changes: 3 additions & 15 deletions src/Twig/ImageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,22 @@ public function getImageHtml($imageView, array $attributes = []): string
$imageView->getExtension(),
$entityName,
$imageView->getType(),
$attributes['size'],
);

$additionalImagesData = $this->imageFacade->getAdditionalImagesDataFromAttributes(
$this->domain->getCurrentDomainConfig(),
$imageView->getId(),
$imageView->getExtension(),
$entityName,
$imageView->getType(),
$attributes['size'],
);

$attributes['alt'] = $imageView->getName();

return $this->getImageHtmlByEntityName($attributes, $entityName, $additionalImagesData);
return $this->getImageHtmlByEntityName($attributes, $entityName);
}

return parent::getImageHtml($imageView, $attributes);
}

/**
* @param \Shopsys\FrameworkBundle\Component\Image\Image|\Shopsys\ReadModelBundle\Image\ImageView|object $imageView
* @param string|null $sizeName
* @param string|null $type
* @return string
*/
public function getImageUrl($imageView, $sizeName = null, $type = null)
protected function getImageUrl($imageView, ?string $type = null): string
{
if ($imageView instanceof ImageView) {
$entityName = $imageView->getEntityName();
Expand All @@ -68,10 +57,9 @@ public function getImageUrl($imageView, $sizeName = null, $type = null)
$imageView->getExtension(),
$entityName,
$type,
$sizeName,
);
}

return parent::getImageUrl($imageView, $sizeName, $type);
return parent::getImageUrl($imageView, $type);
}
}

0 comments on commit cc6b51b

Please sign in to comment.