I would like to extract the article's intro image and insert it into the head for Facebook's og:image metadata. The problem is, I can't seem to get the correct information to fill in. Here's what I've tried...
<?php echo '<meta property="og:image" content="'.$images->image_fulltext.'">';
?>
<?php echo '<meta property="og:image" content="'.JLayoutHelper::render('joomla.content.intro_image', $this->item).'">';
?>
Also tried:
$doc = JFactory::getDocument();
$images = json_decode($this->item->images);
$fbimage = JURI::base() . $images->image_fulltext;
$doc->addCustomTag( '<meta property="og:image" content="' . $fbimage . '">' );
All I get out is <meta property="og:image" content="">
What do I need to to to grab the FQDN of either the article image or the intro image?
You can try below code -
$doc = JFactory::getDocument();
$doc->addCustomTag('<meta property="og:image" content="'. Juri::root() . $images->image_fulltext .'">');
Juri::root()
returns the site URL. More detail about Juri Class
In order to get intro image or full image path you can refer this link.