Skip to content

Commit

Permalink
Added an extra if loop to retrieve description values from sites like…
Browse files Browse the repository at this point in the history
… the New York Times who have malformed it by using value instead of content. See http://www.nytimes.com/2012/06/13/world/middleeast/violence-in-syria-continues-as-protesters-killed.html for an example of this bad code.
  • Loading branch information
AramZS committed Jun 12, 2012
1 parent 7fc9bf1 commit f8dcc99
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions OpenGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ static private function _parse($HTML) {
$key = strtr(substr($tag->getAttribute('property'), 3), '-', '_');
$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.
if ($tag ->hasAttribute('value') && $tag->hasAttribute('property') &&
strpos($tag->getAttribute('property'), 'og:') === 0) {
$key = strtr(substr($tag->getAttribute('property'), 3), '-', '_');
$page->_values[$key] = $tag->getAttribute('value');
}

}

if (empty($page->_values)) { return false; }
Expand Down

0 comments on commit f8dcc99

Please sign in to comment.