How displaying OpenGraph image tag only in articles

General questions relating to Joomla! 1.5 There are other boards for more specific help on Joomla! features and extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Locked
KRV2
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Sun Apr 19, 2020 8:27 pm

How displaying OpenGraph image tag only in articles

Post by KRV2 » Sun Apr 19, 2020 8:34 pm

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

KRV2
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Sun Apr 19, 2020 8:27 pm

Re: How displaying OpenGraph image tag only in articles

Post by KRV2 » Sun Apr 19, 2020 9:13 pm

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!


Locked

Return to “General Questions/New to Joomla! 1.5”