Skip to content

Commit

Permalink
Use default og image if url is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrsky committed Mar 6, 2024
1 parent aa3c793 commit 505e837
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion helfi_tpr.tokens.inc
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,21 @@ function helfi_tpr_tokens(

$image_style = ImageStyle::load('og_image');

$default_image = '';

// Module might not be installed, or it has incompatible version.
if (function_exists('helfi_base_content_get_default_og_image_url')) {
$default_image = helfi_base_content_get_default_og_image_url();
}

foreach ($tokens as $name => $original) {
if ($name === 'label') {
$replacements[$original] = $entity->label();
}

if ($entity instanceof Unit) {
if ($name === 'picture') {
$replacements[$original] = $entity->getPictureUrl($image_style);
$replacements[$original] = $entity->getPictureUrl($image_style) ?? $default_image;
}
}

Expand Down

0 comments on commit 505e837

Please sign in to comment.