Skip to content

Commit

Permalink
fixe: issue with webp variation not taking the focuspoint into account
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian ALEXANDRE committed Apr 2, 2024
1 parent eb767f0 commit 14c1584
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/lib/Imagine/FocusedImageAliasGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ protected function getFocusPoint(\Ibexa\Core\FieldType\Value $fieldValue, string
return null;
}

protected function isFocusedThumbnail(string $variationName): bool
{
$variationConfig = $this->filterConfiguration->get($variationName);
if (isset($variationConfig['filters']['focusedThumbnail'])) {
return true;
}
if ($variationConfig['reference']) {
return $this->isFocusedThumbnail($variationConfig['reference']);
}

return false;
}

/**
* {@inheritdoc}
*
Expand All @@ -114,8 +127,7 @@ public function getVariation(Field $field, VersionInfo $versionInfo, $variationN
$focusPoint = $this->getFocusPoint($field->value, $variationName);

if (IORepositoryResolver::VARIATION_ORIGINAL !== $variationName) {
$variationConfig = $this->filterConfiguration->get($variationName);
if (isset($variationConfig['filters']['focusedThumbnail'])) {
if ($this->isFocusedThumbnail($variationName)) {
$parameters = [
'filters' => [
'focusedThumbnail' => [
Expand Down
5 changes: 4 additions & 1 deletion src/lib/Imagine/ImageAliasGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,13 @@ private function applyFilter(BinaryInterface $image, string $variationName, arra
isset($filterConfig['reference']) &&
IORepositoryResolver::VARIATION_ORIGINAL !== $filterConfig['reference']
) {
unset($runtimeFiltersConfig['filters']);
$image = $this->applyFilter($image, $filterConfig['reference'], $runtimeFiltersConfig);
}

if (!isset($filterConfig['filters']['focusedThumbnail'])) {
unset($runtimeFiltersConfig['filters']['focusedThumbnail']);
}

return $this->filterManager->applyFilter($image, $variationName, $runtimeFiltersConfig);
}

Expand Down

0 comments on commit 14c1584

Please sign in to comment.