Keyword

Open Graph: Image

  • scene66
  • scene66's Avatar Topic Author
  • Offline
  • New Member
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

Please Log in or Create an account to join the conversation.

More
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.

More
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.

More
12 years 5 months ago #63065 by Andrii Natalukha
Replied by Andrii Natalukha on topic Re: Open Graph: Image
yes
from above

Please Log in or Create an account to join the conversation.

More
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

Please Log in or Create an account to join the conversation.

More
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.

More
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 ?

Please Log in or Create an account to join the conversation.

More
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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 5 months ago #63070 by Krikor Boghossian
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.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
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.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum