Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added check for existing key, if key already exists, the entry is cha… #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions OpenGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,18 @@ static private function _parse($HTML) {
$nonOgDescription = null;

foreach ($tags AS $tag) {
if ($tag->hasAttribute('property') &&
strpos($tag->getAttribute('property'), 'og:') === 0) {
if ($tag->hasAttribute('property') && strpos($tag->getAttribute('property'), 'og:') === 0) {
$key = strtr(substr($tag->getAttribute('property'), 3), '-', '_');
$page->_values[$key] = $tag->getAttribute('content');

if(isset($key)){
if(!is_array($page->_values[$key])){
$temp = $page->_values[$key];
$page->_values[$key] = array($temp);
}
$page->_values[$key][] = $tag->getAttribute('content');
}else{
$page->_values[$key] = $tag->getAttribute('content');
}
}

//Added this if loop to retrieve description values from sites like the New York Times who have malformed it.
Expand Down