- Posts: 17
COMMUNITY FORUM
Open Graph: Image
- scene66
-
Topic Author
- Offline
- New Member
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
- Posts: 5
<?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
- Posts: 6
Please Log in or Create an account to join the conversation.
- Andrii Natalukha
-
- Offline
- New Member
- Posts: 5
from above
Please Log in or Create an account to join the conversation.
- Matthew Gray
-
- Offline
- New Member
- Posts: 13
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
- Posts: 37
Please Log in or Create an account to join the conversation.
- Shakensoul
-
- Offline
- New Member
- Posts: 2
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
- Posts: 2
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
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.
Please Log in or Create an account to join the conversation.
- volkan
-
- Offline
- New Member
- Posts: 2
'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.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- flavio
-
- Offline
- New Member
- Posts: 2
I still have problem with Thumbnail of item on facebook with k2.
My version is recent 2.6.6, but i don't know how can I configure this settings.
I use also the plugin Phoca Open Graph Plugin
Many links posted on Facebook are shown wrong, got other posts. :silly:
Tks
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
You can specify the image you want to show (must be at least 200px in both dimensions) in the component's params.
As for the Phoca Open Graph Plugin I am not sure you need this for K2 and I cannot tell you it will not create conflicts as well.
Please Log in or Create an account to join the conversation.
- scene66
-
Topic Author
- Offline
- New Member
- Posts: 17
Thank you — I did not see your answer until now!Andrii Natalukha wrote:
<?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.
- YannisDr
-
- Offline
- Junior Member
- Posts: 28
I can't understand what the heck the "Image size to use when posting K2 items on Facebook" dropdown selection is for! There is absolutely NO change when touching this.
And IMHO, I think it is stupid to have a 200x200px picture when user opens an item just to make it possible to fit in a FB post. I don't get why can't it be possible to have a nice flat wide image picture instead?
Edit: the only difference I see when i touch the "image size to use when posting k2 items on FB" is when I see the source of the page: og:image's value is M, L, XL or whatever I choose.
Please Log in or Create an account to join the conversation.
- YannisDr
-
- Offline
- Junior Member
- Posts: 28
More:
stackoverflow.com/questions/1138460/how-does-facebook-sharer-select-images
developers.facebook.com/tools/debug
However, in Facebook debugger tool I can see that K2 needs to fix some important aspects, such as the warning about: "Admins And App ID Missing" or this: "og:image should be larger" while I have chosen the XL size from the parameters.
Please Log in or Create an account to join the conversation.
- Marcel Beck
-
- Offline
- New Member
- Posts: 3
darkslayer wrote: Where do i need to put that code so facebook gets the image from my k2 article? is it in item.php?
Where exactly???
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
- Posts: 8743
You do not need to type any code. Just ensure that you are using K2 2.6.8. Then go to K2 parameters and select the desired image size for Facebook.
Please Log in or Create an account to join the conversation.
- Marcel Beck
-
- Offline
- New Member
- Posts: 3
Lefteris Kavadas wrote: @Marcel Beck
You do not need to type any code. Just ensure that you are using K2 2.6.8. Then go to K2 parameters and select the desired image size for Facebook.
I've tried everything, updating code, back to stock code, updating to K2 2.6.8 and it is still the same when I post on Facebook. Then I adjusted the sizes of the image parameters as well to fit the requirements still nothing, the debug too doesn't even scrape my site....
What are my options?
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
- Posts: 8743
Please Log in or Create an account to join the conversation.