Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • cyrusxxx Friend
    #1077157

    Hello I have one question concerning open graph tags.
    I have implemented Facebook open graph tags for my articles creating template override and inserting this code:
    [code]//opengraph
    if (isset($images->image_intro) and !empty($images->image_intro))
    {
    $timage= htmlspecialchars(JURI::root().$images->image_intro);

    }

    elseif (isset($images->image_fulltext) and !empty($images->image_fulltext))
    {
    $timage= htmlspecialchars(JURI::root().$images->image_fulltext);
    }
    else
    {
    $timage= ‘https://xxxxx.jpg‘;
    }
    $doc =& JFactory::getDocument();
    $doc->addCustomTag( ‘<meta name="twitter:title" content="’.$this->escape($this->item->title).’">
    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:site" content="@xxxxxxx">
    <meta name="twitter:creator" content="@xxxxxxxxx">
    <meta name="twitter:url" content="’.str_replace(‘" ‘,’"’,JURI::current()).’"="">
    <meta name="twitter:description" content="’.strip_tags($this->item->introtext).’">
    <meta name="twitter:image" content="’.$timage.’">
    <meta property="og:title" content="’.$this->escape($this->item->title).’"/>
    <meta property="og:type" content="article"/>
    <meta property="og:email" content="xxxxxxxxxx";/>
    <meta property="og:url" content="’.str_replace(‘" ‘,’"’,juri::current()).’"="">
    <meta property="og:image" content="’.$timage.’"/>
    <meta property="og:site_name" content="xxxxxxxxxx"/>
    <meta property="fb:admins" content="xxxxxxxx"/>
    <meta property="og:locale" content="xxxxxx" />
    <meta property="og:description" content="’.strip_tags($this->item->introtext).’"/>
    ‘);
    ?>[/code]

    and with this code article meta is displayed properly.
    But now if I insert in meta property image for main domain in template head section that image overrides article image set in default.php template override.

    Can anyone tell me how to set open graph image for main domain and not to override articles image when shared?

    Thank you!

    Pankaj Sharma Moderator
    #1077217

    Hi
    head files is same for all the site pages, In case you want to apply the meta to specific layout you have to use PHP if else statement to define to code for a particular menu id or you can define them on the layout files, for example, category blog file override will be in the template folder /html/com_content/category .

    Regards

    cyrusxxx Friend
    #1077240

    I see now, same thing just for other overrides.
    But in category blog override I think if else is not needed because there is no intro and full article image.

    Thank you very much Pankraj for clarifying this to me.

    Pankaj Sharma Moderator
    #1077295

    You are welcome!

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

This topic contains 3 replies, has 2 voices, and was last updated by  Pankaj Sharma 6 years, 4 months ago.

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