From 31d9199f3e9f42d072af58a39b78ea0d713795e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto-Pekka=20Nyka=CC=88nen?= Date: Thu, 8 Dec 2022 08:29:05 +0200 Subject: [PATCH 1/2] added prefix to og tags for linkedin --- .../helfi_rekry_content/helfi_rekry_content.module | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/public/modules/custom/helfi_rekry_content/helfi_rekry_content.module b/public/modules/custom/helfi_rekry_content/helfi_rekry_content.module index 3261b22b..cc5a6307 100644 --- a/public/modules/custom/helfi_rekry_content/helfi_rekry_content.module +++ b/public/modules/custom/helfi_rekry_content/helfi_rekry_content.module @@ -285,3 +285,13 @@ function helfi_rekry_content_preprocess_block(&$variables) { } } } + +function helfi_rekry_content_page_attachments_alter(array &$attachments) { + $og_tags = ['og_site_name', 'og_url', 'og_title', 'og_image_0']; + + foreach ($attachments["#attached"]["html_head"] as $key => $attachment) { + if (isset($attachment[1]) && in_array($attachment[1], $og_tags)) { + $attachments["#attached"]["html_head"][$key][0]['#attributes']['prefix'] = 'og: http://ogp.me/ns#'; + } + } +} From 980d7cab421c8ae4263edd2a40fe276c46be27b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto-Pekka=20Nyka=CC=88nen?= Date: Thu, 8 Dec 2022 08:31:27 +0200 Subject: [PATCH 2/2] added function comment --- .../custom/helfi_rekry_content/helfi_rekry_content.module | 3 +++ 1 file changed, 3 insertions(+) diff --git a/public/modules/custom/helfi_rekry_content/helfi_rekry_content.module b/public/modules/custom/helfi_rekry_content/helfi_rekry_content.module index cc5a6307..66627cee 100644 --- a/public/modules/custom/helfi_rekry_content/helfi_rekry_content.module +++ b/public/modules/custom/helfi_rekry_content/helfi_rekry_content.module @@ -286,6 +286,9 @@ function helfi_rekry_content_preprocess_block(&$variables) { } } +/** + * Implements hook_page_attachments_alter(). + */ function helfi_rekry_content_page_attachments_alter(array &$attachments) { $og_tags = ['og_site_name', 'og_url', 'og_title', 'og_image_0'];