Topic: Using more than one image for open graph meta tags

Hello,

I use Nibbleblog 4.05 with the open graph plugin.

This plugin sets the "image.png" in the theme path as standard for all postings.

Is it possible to use other images than "image.png", e. g. the image of an actual blog posting?

Re: Using more than one image for open graph meta tags

Okay, this is solved (far away from beeing a 'professional' solution).

I changed the open_graph plugin to

<?php
// =====================================================================
// PLUGIN INFO
// =====================================================================
$_PLUGIN_CONFIG['DATA'] = array(
    'author'=>'Da Elsta + Diego Najar',
    'version'=>'3.7',
    'url'=>'http://www.nibbleblog.com'
);

// =====================================================================
// PLUGIN CLASS
// =====================================================================
class PLUGIN_OPEN_GRAPH extends Plugin
{
    public function blog_head()
    {
        global $post;
        global $page;
        global $where_am_i;
        global $settings;
        global $category;
        global $seo;
        global $tag;

      $srvsubstra = substr($settings["url"], 0, -1);
      $srvsubstrb = substr($_SERVER["REQUEST_URI"], 0, -1);
      $srvsubstrc = ".";
      $srvsubstrd = "/media";
      $srvsubstre = "/og.png";
      $srvstra = $srvsubstra.$srvsubstrb.$srvsubstrd.$srvsubstre;
      $srvstrb = $srvsubstrc.$srvsubstrb.$srvsubstrd.$srvsubstre;
      $srvstrc = $srvsubstrc.$srvsubstrb.$srvsubstrd;
      

        $og = array(
            'locale'=>$settings['locale'],
            'type'=>'website',
            'title'=>$seo['site_title'],
            'description'=>$seo['site_description'],
         'image'=>$srvstra,
//            'image'=>$settings['url'].HTML_PATH_ADMIN_TEMPLATES.'default/css/img/mrnibbler128.png',
            'url'=>BLOG_URL,
            'site_name'=>$seo['site_title'],
            'tags'=>''
        );

        // The theme has og:image ?
      if(!file_exists($srvstrc))
         mkdir($srvstrc, 0777, true);
         
      
//        if(file_exists(THEME_IMG.'image.png'))
//            $og['image'] = $settings['url'].HTML_THEME_IMG.'image.png';

        if( ($where_am_i[1]=='post') && !empty($post) )
        {
            $og['type']            = 'article';
            $og['title']        .= ' - '.$post['title'];
            $og['description']    = $post['description'];
            $og['url']            = Url::post($post, true);

            // tags
            $og['tags'] .= '<meta property="article:tag" content="'.$post['category'].'">'.PHP_EOL;
            foreach($post['tags'] as $tag)
                $og['tags'] .= '<meta property="article:tag" content="'.$tag['name_human'].'">'.PHP_EOL;
        }
        elseif( ($where_am_i[1]=='page') && !empty($page) )
        {
            $og['type']         = 'article';
            $og['title']         .= ' - '.$page['title'];
            $og['description']    = $page['description'];
            $og['url']            = Url::page($page, true);
        }
        elseif( ($where_am_i[1]=='category') && !empty($category) )
        {
            $og['type']            = 'article';
            $og['title']        .= ' - '.$category['name'];
            $og['url']            = Url::category($category['slug'], true);
        }
        elseif( ($where_am_i[1]=='tag') && !empty($tag) )
        {
            $og['type']            = 'article';
            $og['title']        .= ' - '.$tag;
            $og['url']            = Url::tag($tag, true);
        }

        $html  = PHP_EOL.'<!-- Open Graph -->'.PHP_EOL;
        $html .= '<meta property="og:locale" content="'.$og['locale'].'">'.PHP_EOL;
        $html .= '<meta property="og:type" content="'.$og['type'].'">'.PHP_EOL;
        $html .= '<meta property="og:title" content="'.$og['title'].'">'.PHP_EOL;
        $html .= '<meta property="og:description" content="'.$og['description'].'">'.PHP_EOL;
        $html .= '<meta property="og:image" content="'.$og['image'].'">'.PHP_EOL;
        $html .= '<meta property="og:url" content="'.$og['url'].'">'.PHP_EOL;
        $html .= '<meta property="og:site_name" content="'.$og['site_name'].'">'.PHP_EOL;
        $html .= $og['tags'];
     
        return $html;
    }
}
?>

Now for all pages, categories and posts a subfolder 'media' will be created, and the og:image-tag will contain a image 'og.png' - that must be added manually to the 'media'-folder of the post-url.