Page 1 of 1

How displaying OpenGraph image tag only in articles

Posted: Sun Apr 19, 2020 8:34 pm
by KRV2
Hi!
I can't find a solution how to print og:image in articles.
I only found a solution for Joomla 2.5:

$doc = JFactory::getDocument();
$images = json_decode($this->item->images);
$fbimage = JURI::base() . $images->image_fulltext;
$doc->addCustomTag( '<meta property="og:image" content="' . $fbimage . '">' );

I would be very grateful if anyone advised a similar one for Joomla 1.5

Re: How displaying OpenGraph image tag only in articles

Posted: Sun Apr 19, 2020 9:13 pm
by KRV2
actively testing different solutions by stuffing code in /com_content/article/default.php

$doc = JFactory::getDocument();
if(preg_match('/<\s*img[^>]+>/Ui',$this->item->text,$matches)){
$image=$matches[1]
}
$doc->addCustomTag( '<meta property="og:image" content="' . $image . '">' );

But doesnt work ((
Something help me!