Is there any possibility to select only the image from the introtext or the fulltext image? The plugin creates a tag for all the images found on an page, even the ads images.
kind regards
Open graph introtext or fulltext image
- Jan
- Phoca Hero
- Posts: 48402
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Open graph introtext or fulltext image
Hi, see the php code:
it joins fulltext and introtext and tries to find the first image.
So you can customize it to fit your rules.
Jan
Code: Select all
// 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 != '') {
$fulltext = $row->introtext;
}
$content = $introtext . $fulltext;
preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $content, $src);
if (isset($src[1]) && $src[1] != '') {
$document->setMetadata('og:image', JURI::base(false).htmlspecialchars($src[1]));
$img = 1;
}
So you can customize it to fit your rules.
Jan
If you find Phoca extensions useful, please support the project
-
- Phoca Newbie
- Posts: 1
- Joined: 10 Oct 2014, 11:48
Re: Open graph introtext or fulltext image
It seems to be a bug in that code.Jan wrote:Hi, see the php code:
Code: Select all
// 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 != '') { ------>$fulltext = $row->introtext; } $content = $introtext . $fulltext;
The $fulltext variable is assigned to the $row->introtext value if the introtext exists and $introtext is never assigned
- Jan
- Phoca Hero
- Posts: 48402
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Open graph introtext or fulltext image
Hi, yes, it seems to be, which version you are using?
Jan
Jan
If you find Phoca extensions useful, please support the project
- Jan
- Phoca Hero
- Posts: 48402
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Open graph introtext or fulltext image
If you find Phoca extensions useful, please support the project