There seems to be several things I don't (yet!) understand about OpenGraph and the plugin, but the first thing I'm trying to understand is how to set the image properly: because some articles don't have an image, I just want the same image on all pages - the site logo.
I've set the logo on Article Options, Featured Options and Category (Blog) Options to be this logo. I have three pages I'm trying to sort out to start with: the home page with a featured news article, the news page with a category blog of news articles and pages of individual news articles.
On the home page, I have two share buttons: one at the bottom of the featured article and one from a module that displays below the featured article. This (I hope) allows the article to be shared or the home page itself. However, although I get the right image for the article, the home page one picks up the graphic from the featured article. Looking at the source for that page shows absolutely no og: parameters at all!
I could describe what happens to the other pages (the single article page has the og: data, but the category blog page also has no og: data), but hopefully that's enough for now.
There also seems to be some issues with the description text (I have Introtext As Description set to yes, but it doesn't display), but it perhaps might be good to get the images sorted first.
So, why is there no og: data on the home page and why isn't my selected image being used?
What have I misunderstood and what am I doing wrong?
Problems with images and description
- Jan
- Phoca Hero
- Posts: 48689
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Problems with images and description
Hi, first of all, the plugin is a content plugin, which means, it does the information only when article is displayed on the page.
So on page, where one article is displayed or on blog page where more articles are displayed (on blog page, the latest article is selected to get the data)
See similar posts or code of the plugin to see how exactly the displaying of images works:
1) get the image from parameters
2) if not set then from parameters of article - image_intro
3) if not set then from parameters of article - image_fulltext
(I will recommend, you set the images for these parameters)
4) if not set then the script tries to find some image from the article
5) if there is no image in article, it tries to find some in the folder images/phocaopengraph
So there are 5 places where the image is searched and all this can be influenced by
This process was voted by users, but it is not difficult to change other ordering of events. See:
https://www.phoca.cz/documents/70-phoca- ... open-graph
Jan
So on page, where one article is displayed or on blog page where more articles are displayed (on blog page, the latest article is selected to get the data)
See similar posts or code of the plugin to see how exactly the displaying of images works:
Code: Select all
// Image
$pictures = json_decode($row->images);
if ($this->params->get('image'.$suffix, '') != '') {
plgContentPhocaOpenGraphHelper::renderTag('og:image', JURI::base(false).$this->params->get('image'.$suffix, ''), $type);
} else if (isset($pictures->{'image_intro'}) && $pictures->{'image_intro'} != '') {
plgContentPhocaOpenGraphHelper::renderTag('og:image', JURI::base(false).$pictures->{'image_intro'}, $type);
} else if (isset($pictures->{'image_fulltext'}) && $pictures->{'image_fulltext'} != '') {
plgContentPhocaOpenGraphHelper::renderTag('og:image', JURI::base(false).$pictures->{'image_fulltext'}, $type);
} else {
// Try to find image in article
$img = 0;
$fulltext = '';
if (isset($row->fulltext) && $row->fulltext != '') {
$fulltext = $row->fulltext;
}
$introtext = '';
if (isset($row->introtext) && $row->introtext != '') {
$introtext = $row->introtext;
}
$content = $introtext . $fulltext;
preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $content, $src);
if (isset($src[1]) && $src[1] != '') {
plgContentPhocaOpenGraphHelper::renderTag('og:image', JURI::base(false).$src[1], $type);
$img = 1;
}
// Try to find image in images/phocaopengraph folder
if ($img == 0) {
if (isset($row->id) && (int)$row->id > 0) {
jimport( 'joomla.filesystem.file' );
$imgPath = '';
$path = JPATH_ROOT . '/images/phocaopengraph/';
if (JFile::exists($path . '/' . (int)$row->id.'.jpg')) {
$imgPath = JURI::base(false) . 'images/phocaopengraph/'.(int)$row->id.'.jpg';
} else if (JFile::exists($path . '/' . (int)$row->id.'.png')) {
$imgPath = JURI::base(false) . 'images/phocaopengraph/'.(int)$row->id.'.png';
} else if (JFile::exists($path . '/' . (int)$row->id.'.gif')) {
$imgPath = JURI::base(false) . 'images/phocaopengraph/'.(int)$row->id.'.gif';
}
if ($imgPath != '') {
plgContentPhocaOpenGraphHelper::renderTag('og:image', $imgPath, $type);
}
}
}
}
2) if not set then from parameters of article - image_intro
3) if not set then from parameters of article - image_fulltext
(I will recommend, you set the images for these parameters)
4) if not set then the script tries to find some image from the article
5) if there is no image in article, it tries to find some in the folder images/phocaopengraph
So there are 5 places where the image is searched and all this can be influenced by
This process was voted by users, but it is not difficult to change other ordering of events. See:
https://www.phoca.cz/documents/70-phoca- ... open-graph
Jan
If you find Phoca extensions useful, please support the project
-
- Phoca Newbie
- Posts: 4
- Joined: 10 Apr 2016, 01:52
Re: Problems with images and description
Thanks, Jan.
I understand the order of precedence, which is why I set the logo in the preferences. I hadn't realised that being a plugin meant it acted only on articles, but I can't see how that explains why there is no og data on the home page (which has a featured article) or the category blog page (which has a number of articles). Without the og: data, I can only assume Facebook picks images for itself.
So, why are there no og data on those pages?
I understand the order of precedence, which is why I set the logo in the preferences. I hadn't realised that being a plugin meant it acted only on articles, but I can't see how that explains why there is no og data on the home page (which has a featured article) or the category blog page (which has a number of articles). Without the og: data, I can only assume Facebook picks images for itself.
So, why are there no og data on those pages?
- Jan
- Phoca Hero
- Posts: 48689
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Problems with images and description
Hi, which pages you exactly mean? In Joomla! pages are created by many many different component - e.g. article (com_content) is displayed by com_content component, image gallery is displayed by image gallery, maps are displayed by maps component.So, why are there no og data on those pages?
Phoca Opengraph plugin is a com_content (article) plugin, which is applied in content (article) - Joomla! allows it to run in article, not in other parts, so this is why the plugin is able to display the og data only on pages where it is allowed to do (article, blog with articles partially - first article is used for the data)
Jan
If you find Phoca extensions useful, please support the project
-
- Phoca Newbie
- Posts: 4
- Joined: 10 Apr 2016, 01:52
Re: Problems with images and description
I've not checked any other pages, but ones that don't have the og data are the home page, which has one featured article from the news category and a couple of other articles, and the news page, which is a category blog layout of the news articles. Are those created by com_content? If not, that would explain the problem.Jan wrote:Hi, which pages you exactly mean? In Joomla! pages are created by many many different component - e.g. article (com_content) is displayed by com_content component, image gallery is displayed by image gallery, maps are displayed by maps component.So, why are there no og data on those pages?
Phoca Opengraph plugin is a com_content (article) plugin, which is applied in content (article) - Joomla! allows it to run in article, not in other parts, so this is why the plugin is able to display the og data only on pages where it is allowed to do (article, blog with articles partially - first article is used for the data)
Jan
- Jan
- Phoca Hero
- Posts: 48689
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Problems with images and description
Hi, they are created by com_content and both "featured" and "category" display the og data from the first article displayed on the page so there should be displayed the og tags 
Jan

Jan
If you find Phoca extensions useful, please support the project
-
- Phoca Newbie
- Posts: 4
- Joined: 10 Apr 2016, 01:52
Re: Problems with images and description
Hmmm... The home page has a short article first, the featured news article and then another short article: http://www.nightingale-collaboration.org/
...but no og: data. Is it because the featured article isn't the first article?
...but no og: data. Is it because the featured article isn't the first article?
- Jan
- Phoca Hero
- Posts: 48689
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Problems with images and description
Hi, yes, the first article is searched, so if you need to search any other, you need to customize the plugin code directly 
Jan

Jan
If you find Phoca extensions useful, please support the project