Skip to content
Snippets Groups Projects
Commit 89381d17 authored by Kevin Paxman's avatar Kevin Paxman
Browse files

ISTWCMS-4104: code standards

parent 81978d0b
No related branches found
No related tags found
1 merge request!56ISTWCMS-4104: adding defaults for metatags
......@@ -17,12 +17,14 @@ use Drupal\webform\WebformSubmissionStorageInterface;
*/
function uw_cfg_common_metatags_attachments_alter(array &$metatag_attachments) {
// Check if the image and og:image fields are empty.
// We do this here instead of in hook_metatags_alter() because we want to check if they're empty after tokens have been applied.
// We also want to support the use case where they don't upload an image, but do manually specify an image.
// Because of where the information is stored, we have to loop through to find it.
// We do this here instead of in hook_metatags_alter() because we want to
// check if they're empty after tokens have been applied.
// We also want to support the use case where they don't upload an image,
// but do manually specify an image.
// Because of where the information is stored, we have to loop to find it.
$found_image_src = FALSE;
$found_og_image = FALSE;
foreach ($metatag_attachments['#attached']['html_head'] as $id => $attachment) {
foreach ($metatag_attachments['#attached']['html_head'] as $attachment) {
if ($attachment[1] == 'image_src') {
$found_image_src = TRUE;
}
......@@ -31,7 +33,7 @@ function uw_cfg_common_metatags_attachments_alter(array &$metatag_attachments) {
}
}
// Define what the fallback image is, so if it changes we only change one thing.
// Define what the fallback image is, so we only need to change it once.
$fallback_image = 'https://uwaterloo.ca/university-of-waterloo-logo-152.png';
// If the image_src field is missing, create one with the UWaterloo logo.
......@@ -42,7 +44,7 @@ function uw_cfg_common_metatags_attachments_alter(array &$metatag_attachments) {
'#attributes' => [
'rel' => "image_src",
'href' => $fallback_image,
]
],
],
1 => 'image_src',
];
......@@ -56,7 +58,7 @@ function uw_cfg_common_metatags_attachments_alter(array &$metatag_attachments) {
'#attributes' => [
'property' => "og:image",
'content' => $fallback_image,
]
],
],
1 => 'og_image_0',
];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment