Skip to content

Commit

Permalink
Refactor MetaDataTrait to handle empty imageSource
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Mar 8, 2024
1 parent 6dbec26 commit 65b09f3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Traits/MetaDataTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ public function registerData($title, $description, $imageSource)
$view->registerMetaTag(['property' => 'og:type', 'content' => 'website']);
$view->registerMetaTag(['property' => 'og:title', 'content' => $title]);
$view->registerMetaTag(['property' => 'og:description', 'content' => $description]);
$view->registerMetaTag(['property' => 'og:image', 'content' => $imageSource]);
if (!empty($imageSource)) {
$view->registerMetaTag(['property' => 'og:image', 'content' => $imageSource]);
}

$view->registerMetaTag(['name' => 'twitter:card', 'content' => 'summary_large_image']);
$view->registerMetaTag(['name' => 'twitter:title', 'content' => $title]);
$view->registerMetaTag(['name' => 'twitter:description', 'content' => $description]);
$view->registerMetaTag(['name' => 'twitter:image', 'content' => $imageSource]);
if (!empty($imageSource)) {
$view->registerMetaTag(['name' => 'twitter:image', 'content' => $imageSource]);
}
}

public function registerEntity(Entity $entity)
Expand Down

0 comments on commit 65b09f3

Please sign in to comment.