Open mutatron opened 10 years ago
thanks, would be great to get this integrated into the main code
Great idea. I went the other direction. It was only giving me the last image and I wanted the first.
$gotImage = 0;
foreach ($tags AS $tag) {
if ($tag->hasAttribute('property') &&
strpos($tag->getAttribute('property'), 'og:') === 0) {
$key = strtr(substr($tag->getAttribute('property'), 3), '-', '_');
if ($key === "image" && $gotImage === 0) {
$gotImage++;
$page->_values[$key] = $tag->getAttribute('content');
}
else if ($key != "image") {
$page->_values[$key] = $tag->getAttribute('content');
}
}
My version isn't pretty, I'm sure....
A web page may have multiple og:image tags, for example, so I made each _value[$key] into an array, and then values are pushed onto the array, like so:
Of course there are a few keys that need to be explicitly handled, like this: