diff --git a/src/OpenGraph.php b/src/OpenGraph.php index 3c97969..a3e69e3 100644 --- a/src/OpenGraph.php +++ b/src/OpenGraph.php @@ -31,11 +31,11 @@ public function fetch($url, $allMeta = null, $lang = null, $options = LIBXML_NOW $metaproperty = ($tag->hasAttribute('property')) ? $tag->getAttribute('property') : $tag->getAttribute('name'); if (!$allMeta && $metaproperty && strpos($tag->getAttribute('property'), 'og:') === 0) { $key = strtr(substr($metaproperty, 3), '-', '_'); - $value = $tag->getAttribute('content'); + $value = $this->get_meta_value($tag); } if ($allMeta && $metaproperty) { $key = (strpos($metaproperty, 'og:') === 0) ? strtr(substr($metaproperty, 3), '-', '_') : $metaproperty; - $value = $tag->getAttribute('content'); + $value = $this->get_meta_value($tag); } if (!empty($key)) { $metadata[$key] = $value; @@ -110,4 +110,17 @@ protected function verify_image_url($url) return false; } } + + protected function get_meta_value($tag) + { + if (!empty($tag->getAttribute('content'))) { + $value = $tag->getAttribute('content'); + } elseif (!empty($tag->getAttribute('value'))) { + $value = $tag->getAttribute('value'); + } else { + $value = ''; + } + + return $value; + } }