From 74c5ac455d263417af4b1b3ee2ca0b18bcfccb74 Mon Sep 17 00:00:00 2001 From: --system Date: Tue, 11 Feb 2025 09:04:05 +0100 Subject: [PATCH] [BUGFIX] og_image and twitter_image now have the correct foreign_match_fields -> tablenames when using the Record functionality --- CHANGELOG.md | 1 + Classes/Record/Builder/TcaBuilder.php | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37e51f98..afd19f61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ We will follow [Semantic Versioning](http://semver.org/). - Optimized images that are used in the Dashboard module and load them directly instead of through `f:image` - Removed old unused images - Translations are now correctly loaded based on the backend locale +- `og_image` and `twitter_image` now have the correct `foreign_match_fields` -> `tablenames` when using the Record functionality ## 10.1.0 January 27, 2025 ### Added diff --git a/Classes/Record/Builder/TcaBuilder.php b/Classes/Record/Builder/TcaBuilder.php index a2298fec..88a49555 100644 --- a/Classes/Record/Builder/TcaBuilder.php +++ b/Classes/Record/Builder/TcaBuilder.php @@ -66,10 +66,10 @@ protected function addDefaultSeoFields(): void 'canonical_link' => $GLOBALS['TCA']['pages']['columns']['canonical_link'], 'og_title' => $GLOBALS['TCA']['pages']['columns']['og_title'], 'og_description' => $GLOBALS['TCA']['pages']['columns']['og_description'], - 'og_image' => $GLOBALS['TCA']['pages']['columns']['og_image'], + 'og_image' => $this->getFileField('og_image'), 'twitter_title' => $GLOBALS['TCA']['pages']['columns']['twitter_title'], 'twitter_description' => $GLOBALS['TCA']['pages']['columns']['twitter_description'], - 'twitter_image' => $GLOBALS['TCA']['pages']['columns']['twitter_image'], + 'twitter_image' => $this->getFileField('twitter_image'), 'twitter_card' => $GLOBALS['TCA']['pages']['columns']['twitter_card'], ], ]; @@ -132,6 +132,15 @@ protected function addDescriptionField(): void ]); } + protected function getFileField(string $tcaField): array + { + $tca = $GLOBALS['TCA']['pages']['columns'][$tcaField]; + if (isset($tca['config']['foreign_match_fields']['tablenames'])) { + $tca['config']['foreign_match_fields']['tablenames'] = $this->record->getTableName(); + } + return $tca; + } + public function getResult(): array { return $GLOBALS['TCA'];