Open Graph - Intro Image

Phoca plugins - support for all Phoca plugins except Phoca Gallery plugins
User avatar
componentegd
Phoca Member
Phoca Member
Posts: 21
Joined: 31 Mar 2015, 22:39
Location: Rio de janeiro - Brazil
Contact:

Open Graph - Intro Image

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

Re: Open Graph - Intro Image

Post by Jan »

Hi, for now there is no such option, added to the feature request list.

Jan
If you find Phoca extensions useful, please support the project
User avatar
componentegd
Phoca Member
Phoca Member
Posts: 21
Joined: 31 Mar 2015, 22:39
Location: Rio de janeiro - Brazil
Contact:

Re: Open Graph - Intro Image

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

Re: Open Graph - Intro Image

Post 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
If you find Phoca extensions useful, please support the project
User avatar
componentegd
Phoca Member
Phoca Member
Posts: 21
Joined: 31 Mar 2015, 22:39
Location: Rio de janeiro - Brazil
Contact:

Re: Open Graph - Intro Image

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

Re: Open Graph - Intro Image

Post by Jan »

Ok
If you find Phoca extensions useful, please support the project
User avatar
componentegd
Phoca Member
Phoca Member
Posts: 21
Joined: 31 Mar 2015, 22:39
Location: Rio de janeiro - Brazil
Contact:

Re: Open Graph - Intro Image

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

Re: Open Graph - Intro Image

Post by Jan »

Hi, which file you are trying to customize and which version of the plugin?

Jan
If you find Phoca extensions useful, please support the project
User avatar
componentegd
Phoca Member
Phoca Member
Posts: 21
Joined: 31 Mar 2015, 22:39
Location: Rio de janeiro - Brazil
Contact:

Re: Open Graph - Intro Image

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

Re: Open Graph - Intro Image

Post 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
If you find Phoca extensions useful, please support the project
Post Reply