public function OpenGraphMeta::harvestImagesFromNode in Open Graph meta tags 7.2
Harvest all images from the given node.
Return value
array(array('title' => , 'alt' => , 'url' =>))
File
- ./
opengraph_meta.common.inc, line 27
Class
Code
public function harvestImagesFromNode($node) {
// extract image fields
$ret = $this
->extractImageFields((array) $node);
// extract all images from body content
$body = $this
->getNodeBody($node);
if (!empty($body)) {
libxml_use_internal_errors(TRUE);
// turn off libxml errors for now
$doc = new DOMDocument();
$doc
->loadHTML($body);
$list = $doc
->getElementsByTagName('img');
for ($i = 0; $list->length > $i; ++$i) {
$item = $list
->item($i);
if ($item
->hasAttribute('src')) {
$url = $item
->getAttribute('src');
if (!empty($url)) {
$thumb_url = image_style_url($this->thumbnailStyle, $url);
$ret[$url] = array(
'title' => $url,
'alt' => $url,
'url' => $thumb_url,
);
}
}
}
libxml_use_internal_errors(FALSE);
// turn libxml errors back on
}
return $ret;
}