Page 1 of 1

Open graph introtext or fulltext image

Posted: 01 Aug 2014, 23:39
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

Re: Open graph introtext or fulltext image

Posted: 03 Aug 2014, 15:17
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

Re: Open graph introtext or fulltext image

Posted: 10 Oct 2014, 11:59
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

Re: Open graph introtext or fulltext image

Posted: 11 Oct 2014, 15:51
by Jan
Hi, yes, it seems to be, which version you are using?

Jan

Re: Open graph introtext or fulltext image

Posted: 11 Oct 2014, 15:56
by Jan