Skip to content

Commit

Permalink
Fix for opengraph tags #1849
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Feb 5, 2018
1 parent 08be06c commit 637308d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* Added a new `Medium::exists()` method to check for file existence
1. [](#improved)
* Better `Page.collection()` filtering support including ability to have non-published pages in collections
1. [](#bugfix)
* Fixed OpenGraph metatags so only Twitter uses `name=`, and all others use `property=` [#1849](https://github.com/getgrav/grav/issues/1849)

# v1.4.0-rc.1
## 01/22/2018
Expand Down
5 changes: 3 additions & 2 deletions system/src/Grav/Common/Page/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -1525,12 +1525,13 @@ public function metadata($var = null)
$separator = strpos($key, ':');
$hasSeparator = $separator && $separator < strlen($key) - 1;
$entry = [
'name' => $key,
'content' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')
];

if ($hasSeparator) {
if ($hasSeparator && !Utils::startsWith($key, 'twitter')) {
$entry['property'] = $key;
} else {
$entry['name'] = $key;
}

$this->metadata[$key] = $entry;
Expand Down

0 comments on commit 637308d

Please sign in to comment.