diff --git a/src/Entity/ContentExtrasTrait.php b/src/Entity/ContentExtrasTrait.php index 65c10fda..1e000309 100644 --- a/src/Entity/ContentExtrasTrait.php +++ b/src/Entity/ContentExtrasTrait.php @@ -34,7 +34,7 @@ trait ContentExtrasTrait return [ 'title' => $this->contentExtension->getTitle($content), - 'image' => $this->contentExtension->getImage($content), + 'image' => $this->contentExtension->getImage($content, true), 'excerpt' => $this->contentExtension->getExcerpt($content), 'link' => $this->contentExtension->getLink($content), 'editLink' => $this->contentExtension->getEditLink($content), diff --git a/src/Twig/ContentExtension.php b/src/Twig/ContentExtension.php index 7ecd76b4..e8ade954 100644 --- a/src/Twig/ContentExtension.php +++ b/src/Twig/ContentExtension.php @@ -125,13 +125,13 @@ class ContentExtension extends AbstractExtension } /** - * @return ImageField|string|null + * @return ImageField|array|null */ - public function getImage(Content $content, bool $onlyPath = false) + public function getImage(Content $content, bool $onlyValues = false) { foreach ($content->getFields() as $field) { if ($field instanceof ImageField) { - return $onlyPath ? $field->getPath() : $field; + return $onlyValues ? $field->getValue() : $field; } } diff --git a/tests/spec/Bolt/Twig/ContentExtensionSpec.php b/tests/spec/Bolt/Twig/ContentExtensionSpec.php index d907e976..d5990331 100644 --- a/tests/spec/Bolt/Twig/ContentExtensionSpec.php +++ b/tests/spec/Bolt/Twig/ContentExtensionSpec.php @@ -24,7 +24,7 @@ use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; class ContentExtensionSpec extends ObjectBehavior { public const TEST_TITLE = 'test title'; - public const TEST_IMAGE = 'kitten.jpg'; + public const TEST_IMAGE = []; public const TEST_EXCERPT = 'test excerpt'; public const TEST_LINK = 'test/link'; public const TEST_FULL_LINK = 'http://localhost/test/link'; @@ -85,7 +85,7 @@ class ContentExtensionSpec extends ObjectBehavior public function it_gets_image_path(Content $content, ImageField $field, Field $otherField): void { - $field->getPath()->shouldBeCalled()->willReturn(self::TEST_IMAGE); + $field->getValue()->shouldBeCalled()->willReturn(self::TEST_IMAGE); $content->getFields()->shouldBeCalled()->willReturn(new ArrayCollection([ $otherField->getWrappedObject(), $field->getWrappedObject(),