test
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • ozzymanson2 Friend
    #183472

    i have problems with og:image generation in com_content. as you can see it’s gave me a bad path to the images from facebook

    <meta property=”og:image” content=”http://ekb.rhrn.co/http://photos-b.ak.fbcdn.net/hphotos-ak-ash3/150692_432801456785249_1355715734_s.jpg”/>

    also i have the same issue in K2, ‘cos K2 doesn’t generate og:image at all

    ozzymanson2 Friend
    #477728

    i’ve add this code to K2

    <?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 );
    ?>

    but it gaves me the same path

    <meta property=”og:image” content=”http://ekb.rhrn.co/http://distilleryimage1.s3.amazonaws.com/c59ff1da504911e293ab22000a9f1919_7.jpg”/>

    how can i solve it?

    arucardx Friend
    #477740

    o.O is that my code from the K2 forum? Well if its outputting your domain on top of the external url, then I guess what you can simply do is to remove JURI::base. It shouldn’t cause any problem if all your images are from external sources. Otherwise, we will need to use strpos and attempt to create another if rule for strings that already contains http://.

    None the less, the code without juri::base should look like this.


    <?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="'.$this->item->image.'"/>';
    }
    else {
    $opengraph_meta .= '<meta property="og:image" content="http://imagedoomain.com/no-image.jpg"/>';
    }
    $fbog->addCustomTag( $opengraph_meta );
    ?>

    Didn’t test it, but let me know if there’s a syntax error or if the output is still wrong.

Viewing 3 posts - 1 through 3 (of 3 total)

This topic contains 3 replies, has 2 voices, and was last updated by  arucardx 12 years ago.

We moved to new unified forum. Please post all new support queries in our New Forum