- Posts: 17
COMMUNITY FORUM
Open Graph: Image
- scene66
- Topic Author
- Offline
- New Member
Less
More
12 years 7 months ago #63062
by scene66
Open Graph: Image was created by scene66
Hi
Is there a solution that will automatically add open graph: image to K2 items?
Thanks in advance
Is there a solution that will automatically add open graph: image to K2 items?
Thanks in advance
Please Log in or Create an account to join the conversation.
- Andrii Natalukha
- Offline
- New Member
Less
More
- Posts: 5
12 years 7 months ago #63063
by Andrii Natalukha
Replied by Andrii Natalukha on topic Re: Open Graph: Image
<?php
$fbog =& JFactory::getDocument();
$opengraph_meta = '
<meta property="og:title" content="'.$this->item->title.'"/>
<meta property="og:type" content="blog"/>
<meta property="og:url" content="'.JURI::getInstance()->toString().'"/>
<meta property="og:site_name" content="YOUR_SITE_NAME"/>
<meta property="fb:admins" content="INSERT_YOUR_FACEBOOK_ID"/>
';
if (!empty($this->item->image)) {
$opengraph_meta .= '<meta property="og:image" content="'.JURI::base().''.$this->item->image.'"/>';
}
else {
$opengraph_meta .= '<meta property="og:image" content="http://imagedoomain.com/no-image.jpg"/>';
}
$fbog->addCustomTag( $opengraph_meta );
?>
Please Log in or Create an account to join the conversation.
- darkslayer
- Offline
- New Member
Less
More
- Posts: 6
12 years 5 months ago #63064
by darkslayer
Replied by darkslayer on topic Re: Open Graph: Image
Where do i need to put that code so facebook gets the image from my k2 article? is it in item.php?
Please Log in or Create an account to join the conversation.
- Andrii Natalukha
- Offline
- New Member
Less
More
- Posts: 5
12 years 5 months ago #63065
by Andrii Natalukha
Replied by Andrii Natalukha on topic Re: Open Graph: Image
yes
from above
from above
Please Log in or Create an account to join the conversation.
- Matthew Gray
- Offline
- New Member
Less
More
- Posts: 13
12 years 5 months ago #63066
by Matthew Gray
Replied by Matthew Gray on topic Re: Open Graph: Image
Thanks so much for that Andrii...
Just a quick one...how can it be changed so that I can choose the 'S' or 'M' sized image instead of the document image?
Cheers,
Matt
Just a quick one...how can it be changed so that I can choose the 'S' or 'M' sized image instead of the document image?
Cheers,
Matt
Please Log in or Create an account to join the conversation.
- Russell English
- Offline
- Junior Member
Less
More
- Posts: 37
12 years 2 months ago #63067
by Russell English
Replied by Russell English on topic Re: Open Graph: Image
Thank you Andrii, this worked perfectly!
Please Log in or Create an account to join the conversation.
- Shakensoul
- Offline
- New Member
Less
More
- Posts: 2
12 years 2 months ago #63068
by Shakensoul
Replied by Shakensoul on topic Re: Open Graph: Image
Thanks. The above solution worked.
As requested earlier, can we specify which image to choose.
Also with the code above, facebook is showing the title as
og:title: <Name of article> - {Site name is missing}
How can we include the sitename along with the article title ?
As requested earlier, can we specify which image to choose.
Also with the code above, facebook is showing the title as
og:title: <Name of article> - {Site name is missing}
How can we include the sitename along with the article title ?
Please Log in or Create an account to join the conversation.
- volkan
- Offline
- New Member
Less
More
- Posts: 2
11 years 5 months ago #63069
by volkan
Replied by volkan on topic Re: Open Graph: Image
how can we past it. when I pate it it gives me error, help please
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
11 years 5 months ago #63070
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Re: Open Graph: Image
Hello Volkan,
The OG metas are used in K2 by default (recent versions) so no need to use this code, just look under the component's parameters for its settingd.
The OG metas are used in K2 by default (recent versions) so no need to use this code, just look under the component's parameters for its settingd.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- volkan
- Offline
- New Member
Less
More
- Posts: 2
11 years 5 months ago #63071
by volkan
Replied by volkan on topic Re: Open Graph: Image
Thank you. I see only
'Social button' code
Your Twitter username
Facebook image size
and I can only change Facebook image size to Large (as item view) but didn't work. Did I look wrong place.
'Social button' code
Your Twitter username
Facebook image size
and I can only change Facebook image size to Large (as item view) but didn't work. Did I look wrong place.
Please Log in or Create an account to join the conversation.