From 623bbc33256e7013a05a35788e0c7021c6cd65a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Thu, 31 Oct 2024 10:22:56 +0100 Subject: [PATCH] Optimised content thumbnail resolving (#441) --- .../FirstMatchingFieldStrategy.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/lib/Repository/Strategy/ContentThumbnail/FirstMatchingFieldStrategy.php b/src/lib/Repository/Strategy/ContentThumbnail/FirstMatchingFieldStrategy.php index 07acac5abe..b764473ebf 100644 --- a/src/lib/Repository/Strategy/ContentThumbnail/FirstMatchingFieldStrategy.php +++ b/src/lib/Repository/Strategy/ContentThumbnail/FirstMatchingFieldStrategy.php @@ -37,19 +37,22 @@ public function getThumbnail(ContentType $contentType, array $fields, ?VersionIn $fieldDefinitions = $contentType->getFieldDefinitions(); foreach ($fieldDefinitions as $fieldDefinition) { - $field = $this->getFieldByIdentifier($fieldDefinition->getIdentifier(), $fields); + if (!$fieldDefinition->isThumbnail()) { + continue; + } + $field = $this->getFieldByIdentifier($fieldDefinition->getIdentifier(), $fields); if ($field === null) { continue; } + if (!$this->contentFieldStrategy->hasStrategy($field->getFieldTypeIdentifier())) { + continue; + } + $fieldType = $this->fieldTypeService->getFieldType($fieldDefinition->getFieldTypeIdentifier()); - if ( - $fieldDefinition->isThumbnail() - && $this->contentFieldStrategy->hasStrategy($field->getFieldTypeIdentifier()) - && !$fieldType->isEmptyValue($field->getValue()) - ) { + if (!$fieldType->isEmptyValue($field->getValue())) { return $this->contentFieldStrategy->getThumbnail($field, $versionInfo); } }