ogImage для Joomla
Joomla 4
Для Joomla 4 установи Phoca Open Graph System Plugin
Joomla 3
Нам необходимо зименить этот файл: /components/com_content/views/article/tmpl/
default
.php
Как копировать и менять модули и компоненты я писал в этой статье.
Во вновь созданном шаблоне после этого кода:
/**
* @package Joomla.Site
* @subpackage com_content
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined(
'_JEXEC'
)
or
die
;
JHtml::addIncludePath(JPATH_COMPONENT .
'/helpers'
);
// Create shortcuts to some parameters.
$params
=
$this
->item->params;
$images
= json_decode(
$this
->item->images);
$urls
= json_decode(
$this
->item->urls);
$canEdit
=
$params
->get(
'access-edit'
);
$user
= JFactory::getUser();
$info
=
$params
->get(
'info_block_position'
, 0);
JHtml::_(
'behavior.caption'
);
Необходимо вставить этот код:
//OpenGraph start
$datepubl
=
$this
->item->created;
if
(isset(
$images
-> image_intro)
and
!
empty
(
$images
-> image_intro)) {
$timage
= htmlspecialchars(JURI :: root().
$images
-> image_intro);
}
elseif
(isset(
$images
-> image_fulltext)
and
!
empty
(
$images
-> image_fulltext)) {
$timage
= htmlspecialchars(JURI :: root().
$images
-> image_fulltext);
}
else
{
$timage
=
'default_logo.jpg'
;
}
$document
=& JFactory :: getDocument();
if
(
$this
->item->metadesc ==
""
) {
$mmd
=
strip_tags
(
$this
->item->introtext);}
else
{
$mmd
=
$this
->item->metadesc;}
$document
-> addCustomTag( '
"og:title"
content=
"'.$this -> escape($this -> item -> title).'"
>
"og:description"
content=
"'.$mmd.'"
>
"og:type"
content=
"article"
>
"og:url"
content=
"'.JURI :: current().'"
>
"og:image"
content=
"'.$timage.'"
>
"og:site_name"
content=
"Название вашего сайта"
>
"article:published_time"
content=
"'.$datepubl.'"
>
"article:author"
content=
"vitalij.litvinov"
>
"fb:admins"
content=
"100001722532567"
>
"fb:app_id"
content=
"949954338426008"
>
');
//OpenGraph end
Как видите все просто. Картинки выводятся по следующему принципу - если нет картинки для вступительной части материала, выводится картинка полного материала, если и ее нет то берется картинка по умолчанию. Ее надо указать заменив на свою в строке
$timage = 'default_logo.jpg';