Code: Select all
<meta property="og:image" content="">
Moderator: General Support Moderators
Code: Select all
<meta property="og:image" content="">
Code: Select all
use Joomla\CMS\Factory; // this one can be already in your override
use Joomla\CMS\Uri\Uri;
$document = Factory::getApplication()->getDocument();
$images = json_decode($this->item->images);
$ogImg = !empty($images->image_fulltext) ? $images->image_fulltext : $images->image_intro;
if ( !empty($ogImg) ) {
$document->addCustomTag('<meta property="og:image" content="' . Uri::base() . $ogImg . '" />');
}
carlitorweb wrote: ↑Fri May 10, 2024 12:59 amNot sure where is the "index.php", but normally this you can do it inside the article view. So, first, make a override to com_content/article.
Then you need the follow code:
Code: Select all
use Joomla\CMS\Factory; // this one can be already in your override use Joomla\CMS\Uri\Uri; $document = Factory::getApplication()->getDocument(); $images = json_decode($this->item->images); $ogImg = !empty($images->image_fulltext) ? $images->image_fulltext : $images->image_intro; if ( !empty($ogImg) ) { $document->addCustomTag('<meta property="og:image" content="' . Uri::base() . $ogImg . '" />'); }
Code: Select all
use Joomla\CMS\Factory; // this one can be already in your override
use Joomla\CMS\Uri\Uri; // this one can be already in your override
use Joomla\CMS\HTML\HTMLHelper; // this one can be already in your override
$document = Factory::getApplication()->getDocument();
$images = json_decode($this->item->images);
$ogImg = !empty($images->image_fulltext) ? $images->image_fulltext : $images->image_intro;
if ( !empty($ogImg) ) {
$ogImg = HTMLHelper::_('cleanImageURL', $ogImg);
$document->addCustomTag('<meta property="og:image" content="' . Uri::base() . $this->escape($ogImg->url) . '" />');
}
Code: Select all
<meta property="og:image" content="/MAIN-IMAGE.png"/>
Code: Select all
$this->category->getParams()->get('image')