Skip to content

Commit

Permalink
Return an empty variation if image does not exist
Browse files Browse the repository at this point in the history
This prevents exceptions with `Impossible to access an attribute ("uri") on a null variable.` in Twig

(cherry picked from commit 3779361)
  • Loading branch information
emodric authored and pspanja committed Feb 17, 2023
1 parent c8c67a4 commit d728160
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bundle/Templating/Twig/Extension/ImageRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(
*
* @return null|\eZ\Publish\SPI\Variation\Values\Variation
*/
public function getImageVariation(Field $field, string $variationName): ?Variation
public function getImageVariation(Field $field, string $variationName): Variation
{
/** @var \eZ\Publish\Core\FieldType\Image\Value $value */
$value = $field->value;
Expand All @@ -60,6 +60,6 @@ public function getImageVariation(Field $field, string $variationName): ?Variati
);
}

return null;
return new Variation();
}
}

0 comments on commit d728160

Please sign in to comment.