Open graph introtext or fulltext image

Phoca plugins - support for all Phoca plugins except Phoca Gallery plugins
diemke
Phoca Newbie
Phoca Newbie
Posts: 1
Joined: 01 Aug 2014, 23:33

Open graph introtext or fulltext image

Post by diemke »

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
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Open graph introtext or fulltext image

Post by Jan »

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;
			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;
			}
it joins fulltext and introtext and tries to find the first image.

So you can customize it to fit your rules.

Jan
If you find Phoca extensions useful, please support the project
golaizola
Phoca Newbie
Phoca Newbie
Posts: 1
Joined: 10 Oct 2014, 11:48

Re: Open graph introtext or fulltext image

Post by golaizola »

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;
It seems to be a bug in that code.
The $fulltext variable is assigned to the $row->introtext value if the introtext exists and $introtext is never assigned
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Open graph introtext or fulltext image

Post by Jan »

Hi, yes, it seems to be, which version you are using?

Jan
If you find Phoca extensions useful, please support the project
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Open graph introtext or fulltext image

Post by Jan »

If you find Phoca extensions useful, please support the project
Post Reply