public function OpenGraphMeta::render_data in Open Graph meta tags 6
Same name and namespace in other branches
- 7 opengraph_meta.common.inc \OpenGraphMeta::render_data()
Render the meta tag data for the given node.
File
- ./
opengraph_meta.common.inc, line 249
Class
Code
public function render_data(&$node, $opengraph_data) {
// fallback values in case no values set.
$allfields = $this
->get_og_tag_defaults($node, TRUE);
foreach ($allfields as $field => $_d) {
// already written this meta tag to output?
if (array_key_exists($field, $this->tags_already_output)) {
$this
->warn(t("Already output og:%s", array(
'%s' => $field,
)));
continue;
}
$v = !empty($opengraph_data[$field]) ? $opengraph_data[$field] : $_d;
if (!empty($v)) {
switch ($field) {
case self::IMAGE:
$v = url(ltrim($v, '/'), array(
'absolute' => TRUE,
));
break;
case self::TITLE:
case self::DESCRIPTION:
case self::STREET_ADDRESS:
case self::LOCALITY:
case self::REGION:
case self::COUNTRY_NAME:
$v = htmlspecialchars(htmlspecialchars_decode($v));
break;
case self::LATITUDE:
case self::LONGITUDE:
$v = floatval($v);
break;
}
// allow other people to alter this value
$v = OpenGraphMetaDrupalLayer::invoke_filter('og_tag_render_alter', $v, array(
$node,
$field,
));
$this->render_obj
->add_meta('og:' . $field, $v);
$this->tags_already_output[$field] = true;
}
// if value available for field
}
// for each field
}