Page 1 of 4

Open Graph - Intro Image

Posted: 09 Apr 2015, 16:41
by componentegd
Hello!
First of all, I love this plugin! I use it always.

I'm trying to use the plugin capturing the image directly from the "Intro image", you can put an image there clicking into "Images and links" and then "Intro image".

Image

I saw a lot of posts in here, but I didn't found any of them talking about it.

Can anyone help me?
Thanks in advance!

Re: Open Graph - Intro Image

Posted: 09 Apr 2015, 19:11
by Jan
Hi, for now there is no such option, added to the feature request list.

Jan

Re: Open Graph - Intro Image

Posted: 09 Apr 2015, 19:33
by componentegd
Jan wrote:Hi, for now there is no such option, added to the feature request list.

Jan
Thank you very much!
Is there anything I can do to help?

Re: Open Graph - Intro Image

Posted: 10 Apr 2015, 19:06
by Jan
Hi, if you are able to customize it (php skills) and you will modify it for your self, will be great to get a guide :idea:

Jan

Re: Open Graph - Intro Image

Posted: 10 Apr 2015, 19:16
by componentegd
Jan wrote:Hi, if you are able to customize it (php skills) and you will modify it for your self, will be great to get a guide :idea:

Jan
Ok. I'll try something and I'll post here soon as I get some answer.
My greatest problem with joomla is that I'm not that good with OO.

Re: Open Graph - Intro Image

Posted: 10 Apr 2015, 19:20
by Jan
Ok

Re: Open Graph - Intro Image

Posted: 10 Apr 2015, 19:48
by componentegd
I manage to find a solution, but I would like a help to make it "pro" solution.

I'll post here the code I used to it, but it only will work if there is no image into the article, only in the "intro image".

Code: Select all

// Article Image
			$article = JTable::getInstance("content"); 
			$article->load(JRequest::getInt("id")); // Get Article ID
			$article_images = $article->get("images"); // Get image parameters
			$pictures = json_decode($article_images); // Split the parameters apart
			// Print the image
			//echo "<img src='" . $pictures->{'image_intro'} . "' alt='" . $pictures->{'image_intro_alt'} . "'>";
			$document->setMetadata('og:image', $pictures->{'image_intro'});
I'll post now where is it being to work

Code: Select all

// Image
		
		// Article Image
			$article = JTable::getInstance("content"); 
			$article->load(JRequest::getInt("id")); // Get Article ID
			$article_images = $article->get("images"); // Get image parameters
			$pictures = json_decode($article_images); // Split the parameters apart
			// Print the image
			//echo "<img src='" . $pictures->{'image_intro'} . "' alt='" . $pictures->{'image_intro_alt'} . "'>";
			$document->setMetadata('og:image', $pictures->{'image_intro'});
		
		if ($this->params->get('image'.$suffix, '') != '') {
			$document->setMetadata('og:image', JURI::base(false).htmlspecialchars($this->params->get('image'.$suffix, '')));
		} else {
			// Try to find image in article
			$img = 0;
			$fulltext = '';
			if (isset($row->fulltext) && $row->fulltext != '') {
				$fulltext = $row->fulltext;
			}
			
Jan, do you think we can get it to work better? I'm not that expert into PHP skills. Besides, OO kills me lol

Re: Open Graph - Intro Image

Posted: 12 Apr 2015, 23:11
by Jan
Hi, which file you are trying to customize and which version of the plugin?

Jan

Re: Open Graph - Intro Image

Posted: 13 Apr 2015, 15:58
by componentegd
Jan wrote:Hi, which file you are trying to customize and which version of the plugin?

Jan
Hi! I'm using the last version of the plugin.
The file is: "plugins/content/phocaopengraph/phocaopengraph.php"

I just added that code posted above. But I would like to make this work better.

Re: Open Graph - Intro Image

Posted: 15 Apr 2015, 23:04
by Jan
Ok, will be great if you can paste whole code of the phocaopengraph.php

If you will use GIST (on GitHub) will be great - to see the changes.

Jan