Skip to content
Snippets Groups Projects
Commit 82bb21df authored by wodby's avatar wodby Committed by Kevin Paxman
Browse files

ISTWCMS-4104: fixing image_src and og_image metatags

parent b9863120
No related branches found
No related tags found
1 merge request!56ISTWCMS-4104: adding defaults for metatags
......@@ -6,13 +6,13 @@ label: Content
tags:
description: '[node:field_uw_meta_description]'
title: '[current-page:title] | [site:name]'
image_src: '[node:field_uw_meta_image:entity:field_media_image], https://uwaterloo.ca/university-of-waterloo-logo-152.png'
image_src: '[node:field_uw_meta_image:entity:field_media_image]'
canonical_url: '[current-page:url:absolute]'
content_language: '[node:langcode]'
og_description: '[current-page:metatag:description]'
og_updated_time: '[node:changed:custom:c]'
og_title: '[current-page:metatag:title]'
og_image: '[node:field_uw_meta_image:entity:field_media_image], https://uwaterloo.ca/university-of-waterloo-logo-152.png'
og_image: '[node:field_uw_meta_image:entity:field_media_image]'
og_locale: '[current-page:metatag:content_language]_CA'
og_url: '[current-page:url:absolute]'
twitter_cards_type: summary_large_image
......@@ -12,6 +12,22 @@ use Drupal\uw_cfg_common\Service\UWService;
use Drupal\webform\WebformInterface;
use Drupal\webform\WebformSubmissionStorageInterface;
/**
* Implements hook_metatags_alter().
*/
function uw_cfg_common_metatags_alter(array &$metatags, array $context) {
// Get the node entity.
$entity = $context['entity'];
// If there is no associated image, add the fall back university
// logo to image_src and og_image tags.
if (!$entity->field_uw_meta_image->target_id) {
$$metatags['image_src'] = 'https://uwaterloo.ca/university-of-waterloo-logo-152.png';
$metatags['og_image'] = 'https://uwaterloo.ca/university-of-waterloo-logo-152.png';
}
}
/**
* Implements hook_entity_presave().
*/
......
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