forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: Anturaju93 on December 17, 2013, 12:46:13 pm

Title: Open Graph meta data for coppermine
Post by: Anturaju93 on December 17, 2013, 12:46:13 pm
I`m trying to add Open Graph meta data to coppermine gallery:
I manage to add the title and type:
Code: [Select]
<meta property="og:title" content="{TITLE}" />
<meta property="og:type" content="website" />
I want to add the og:url and og:image meta tags, but i need the correct code so that coppermine will generate the unique tags for every page.
What can i use for url and image so i can enable Open Graph meta information for social networks ?
Code: [Select]
<meta property="og:url" content="????????" />
<meta property="og:image" content="?????????" />
I`m editing template.html.
Title: Re: Open Graph meta data for coppermine
Post by: Αndré on December 17, 2013, 01:41:02 pm
If you need unique criteria, I suggest to use the picture ID (pid). Does Open Graph supports something like that, or can you "abuse" some existing field for that information?
Title: Re: Open Graph meta data for coppermine
Post by: Anturaju93 on December 17, 2013, 02:18:29 pm
I`m not a coder, i don`t know how to do that :(
Don`t know what to code to insert to generate a unique image url and picture location to use with open graph.
As you can see if i use 
Code: [Select]
<meta property="og:title" content="{TITLE}" />I get the real page title in the meta content, but what code to insert for
Code: [Select]
<meta property="og:url" content="????????" />
<meta property="og:image" content="?????????" />
so i can get unique url and image file location. How to generate them ?
Title: Re: Open Graph meta data for coppermine
Post by: Αndré on December 17, 2013, 02:42:00 pm
First of all, I don't know Open Graph nor support it. You need to tell us which data you need to insert. Then, we can tell you how to do that.

You said you're currently editing template.html. I assume you just need that meta data for intermediate-sized image pages? Regardless, we probably need to edit theme.php to add data dynamicly.
Title: Re: Open Graph meta data for coppermine
Post by: Anturaju93 on December 17, 2013, 03:44:46 pm
I need a unique url for "og:url" and image location for "og:image" to be generated dynamic.
A custom header witch ads this information on every page...
A simple question is: How to dynamic generate a image url and image location for every page-view and show up on the page.
If open graph works with content="{TITLE}" and generates the page title, it will work with some other code that generates image URL and location.       
Title: Re: Open Graph meta data for coppermine
Post by: Anturaju93 on December 17, 2013, 04:29:44 pm
I think i need to edit theme.php and add this function function pageheader($section, $meta = '') from sample theme but i don't know how to construct the $meta
I tried $meta = <meta property="og:url" content="link here" /> but is not working, my site is crashing.   
Code: [Select]
//meta open graph
    $meta = <<<EOT <meta property="og:url" content="link aici" /> EOT;
Some ideas ?
Title: Re: Open Graph meta data for coppermine
Post by: Anturaju93 on December 17, 2013, 05:00:34 pm
I added this to theme.php :
Code: [Select]
/******************************************************************************
** Section <<<pageheader>>> - START
******************************************************************************/
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

    // Variabile pentru aflarea pid-ului unic START
    $superCage = Inspekt::makeSuperCage();
    $pid = $superCage->get->getInt('pid');
    // Variabile pentru aflarea pid-ului unic END

    $custom_header = cpg_get_custom_include($CONFIG['custom_header_path']);

    $meta = '<meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=$pid" />';

    $charset = ($CONFIG['charset'] == 'language file') ? $lang_charset : $CONFIG['charset'];

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    header("Content-Type: text/html; charset=$charset");
    user_save_profile();

    $template_vars = array(
        '{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => theme_page_title($section),
        '{CHARSET}' => $charset,
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{SYS_MENU}' => theme_main_menu('sys_menu'),
        '{SUB_MENU}' => theme_main_menu('sub_menu'),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
        '{CUSTOM_HEADER}' => $custom_header,
        '{JAVASCRIPT}' => theme_javascript_head(),
        '{MESSAGE_BLOCK}' => theme_display_message_block(),
    );

    $template_vars = CPGPluginAPI::filter('theme_pageheader_params', $template_vars);
    echo template_eval($template_header, $template_vars);

    // Show various admin messages
    adminmessages();
}
/******************************************************************************
** Section <<<pageheader>>> - END
******************************************************************************/

You can see that i defined $meta = '<meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=$pid" />'; witch displays <meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=$pid" /> in browser meta data, but i can`t make the URL to by dynamic: imagini.moinesti.biz/displayimage.php?pid=$pid stays the same and does not change into imagini.moinesti.biz/displayimage.php?pid=140 etc. ...
Title: Re: Open Graph meta data for coppermine
Post by: E. William on December 17, 2013, 10:09:27 pm
Try replacing:
Code: [Select]
    $meta = '<meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=$pid" />';
with:
Code: [Select]
    $meta = '<meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=' . $pid . '" />';
so it doesn't read $pid as part of the url, but as a variable.

Not sure if it'll do the trick, that depends on other parts of the code as well, but it'll get you closer to where you want to be.
Title: Re: Open Graph meta data for coppermine
Post by: Anturaju93 on December 18, 2013, 05:52:31 am
Yes, is working now, thanks.   8)
This is only half fixed, i need now to display this custom meta data only on displayimage.php and i need to insert another meta data into $meta , the image file location for facebook to use with the share button to create a timeline story. <meta property="og:image" content="dynamic and direct path to file location" />
Facebook share looks very nice now with this new open graph data :)
Title: Re: Open Graph meta data for coppermine
Post by: E. William on December 18, 2013, 06:31:47 am
That code would look something like:

Code: [Select]
    $meta = '<meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=' . $pid . '" />';

    if ($CONFIG['make_intermediate'] && cpg_picture_dimension_exceeds_intermediate_limit($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'])) {
        $meta .= '<meta property="og:image" content="http://imagini.moinesti.biz/' . "{$CURRENT_PIC_DATA['filepath']}" . 'normal_' . "{$CURRENT_PIC_DATA['filename']}" . '" />';
    } else {
        $meta .= '<meta property="og:image" content="http://imagini.moinesti.biz/' . "{$CURRENT_PIC_DATA['filepath']}" . "{$CURRENT_PIC_DATA['filename']}" . '" />';
    }

I must say I'm not a coder either, so I can't guarantee this will work. You may have to tweak the code here and there.
Title: Re: Open Graph meta data for coppermine
Post by: Anturaju93 on December 18, 2013, 07:08:23 am
The meta data is displayed only on displayimage.php but like this:
Code: [Select]
<meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=71" /><meta property="og:image" content="http://imagini.moinesti.biz/" />meta property="og:image"  must be a direct link to an intermediate file location and a <br> is needed to show <meta property="og:image" content="http://imagini.moinesti.biz/" /> down on a second line.
Title: Re: Open Graph meta data for coppermine
Post by: E. William on December 18, 2013, 08:53:13 am
Like I said, I'm no coder, so it's gonna be hit and miss :)

Try this:
Code: [Select]
    $meta = '<meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=' . $pid . '" />' . $LINEBREAK;

    if ($CONFIG['make_intermediate'] && cpg_picture_dimension_exceeds_intermediate_limit($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'])) {
        $meta .= '<meta property="og:image" content="http://imagini.moinesti.biz/' . {$CURRENT_PIC_DATA['filepath']} . 'normal_' . {$CURRENT_PIC_DATA['filename']}" . ' />';
    } else {
        $meta .= '<meta property="og:image" content="http://imagini.moinesti.biz/' . {$CURRENT_PIC_DATA['filepath']} . {$CURRENT_PIC_DATA['filename']} . '" />';
    }

The "if" statement is there to link to the fullsize image in case no intermediate file has been generated (for instance if the file dimensions were smaller than those of the intermediate settings or the option has been turned off).
Title: Re: Open Graph meta data for coppermine
Post by: E. William on December 18, 2013, 08:55:11 am
Sorry, left a double quote in there which will result in an empty page...
Here's the correct version (I hope):

Code: [Select]
    $meta = '<meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=' . $pid . '" />' . $LINEBREAK;

    if ($CONFIG['make_intermediate'] && cpg_picture_dimension_exceeds_intermediate_limit($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'])) {
        $meta .= '<meta property="og:image" content="http://imagini.moinesti.biz/' . {$CURRENT_PIC_DATA['filepath']} . 'normal_' . {$CURRENT_PIC_DATA['filename']} . ' />';
    } else {
        $meta .= '<meta property="og:image" content="http://imagini.moinesti.biz/' . {$CURRENT_PIC_DATA['filepath']} . {$CURRENT_PIC_DATA['filename']} . '" />';
    }
Title: Re: Open Graph meta data for coppermine
Post by: E. William on December 18, 2013, 08:58:41 am
You may also want to try leaving the {} out like this:

Code: [Select]
    $meta = '<meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=' . $pid . '" />' . $LINEBREAK;

    if ($CONFIG['make_intermediate'] && cpg_picture_dimension_exceeds_intermediate_limit($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'])) {
        $meta .= '<meta property="og:image" content="http://imagini.moinesti.biz/' . $CURRENT_PIC_DATA['filepath'] . 'normal_' . $CURRENT_PIC_DATA['filename'] . ' />';
    } else {
        $meta .= '<meta property="og:image" content="http://imagini.moinesti.biz/' . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'] . '" />';
    }

This is how I code: Trial and Error ;). See what works, and what doesn't.
Title: Re: Open Graph meta data for coppermine
Post by: Αndré on December 18, 2013, 09:22:34 am
The meta data is displayed only on displayimage.php
I cannot see any code that is responsible to display your additional meta data just on displayimage.php. Have you added anything different you haven't posted yet?
Title: Re: Open Graph meta data for coppermine
Post by: Anturaju93 on December 18, 2013, 09:33:14 am
You may also want to try leaving the {} out like this:

Code: [Select]
    $meta = '<meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=' . $pid . '" />' . $LINEBREAK;

    if ($CONFIG['make_intermediate'] && cpg_picture_dimension_exceeds_intermediate_limit($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'])) {
        $meta .= '<meta property="og:image" content="http://imagini.moinesti.biz/' . $CURRENT_PIC_DATA['filepath'] . 'normal_' . $CURRENT_PIC_DATA['filename'] . ' />';
    } else {
        $meta .= '<meta property="og:image" content="http://imagini.moinesti.biz/' . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'] . '" />';
    }

This is how I code: Trial and Error ;). See what works, and what doesn't.

Not working, now meta data is displayed on all pages, not only displayimage.php.
There is no line break between meta code, and image URL its not generated :
Code: [Select]
<meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=250" /><meta property="og:image" content="http://imagini.moinesti.biz/" />
URL for "og:image" must be dynamic generated like this http://imagini.moinesti.biz/albums/userpics/10001/normal_Toamna_in_Parc_Moinesti_19.jpg , and only be prezent on displayimage.php
Title: Re: Re: Open Graph meta data for coppermine
Post by: Anturaju93 on December 18, 2013, 09:34:32 am
I cannot see any code that is responsible to display your additional meta data just on displayimage.php. Have you added anything different you haven't posted yet?
The code is not working correctly , so i do not leave it on my site yet.
Title: Re: Open Graph meta data for coppermine
Post by: Αndré on December 18, 2013, 09:53:21 am
Use this code:
Code: [Select]
    global $CPG_PHP_SELF, $LINEBREAK, $CURRENT_PIC_DATA;
    if ($CPG_PHP_SELF == 'displayimage.php') {
        $superCage = Inspekt::makeSuperCage();
        $meta .= '<meta property="og:url" content="' . $CONFIG['ecards_more_pic_target'] . 'displayimage.php?pid=' . $superCage->get->getInt('pid') . '" />' . $LINEBREAK;
        $meta .= '<meta property="og:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'] . '" />';
    }
Title: Re: Open Graph meta data for coppermine
Post by: Anturaju93 on December 18, 2013, 10:08:58 am
Yes Andre, working all okay now.
Thanks Andre and William for your help :)
Facebook debugger:
https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fimagini.moinesti.biz%2Fdisplayimage.php%3Fpid%3D775%23top_display_media
Title: Re: Re: Open Graph meta data for coppermine
Post by: netb on January 18, 2015, 04:29:29 pm
Use this code:
Code: [Select]
    global $CPG_PHP_SELF, $LINEBREAK, $CURRENT_PIC_DATA;
    if ($CPG_PHP_SELF == 'displayimage.php') {
        $superCage = Inspekt::makeSuperCage();
        $meta .= '<meta property="og:url" content="' . $CONFIG['ecards_more_pic_target'] . 'displayimage.php?pid=' . $superCage->get->getInt('pid') . '" />' . $LINEBREAK;
        $meta .= '<meta property="og:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'] . '" />';
    }

Hello,

I used this code and it works like a charm for which I thank you but now it seems that it doesn't quite fit my requirements.
Sharing services like addthis and also the generic facebook share use these meta tags and don't display any image when they are missing.
So could it be possible also to display the meta tags for og:url and og:image in the thumbnails.php also?

This can be debugged here for instance - https://developers.facebook.com/tools/debug/og/object/ to see what will be the share result and if you share from thumbnails.php there is no image.
For the test I share for example Last Additions from http://www.greatmusclebodies.com/thumbnails.php?album=lastup&cat=0 and I want the og:url tag to be in there with a og:image tag for an image (it doesn't matter which image as long as there is one).

I hope you understand what I mean.

Is it possible to also to display the

Title: Re: Open Graph meta data for coppermine
Post by: Αndré on January 28, 2015, 09:41:53 pm
Updated code:
Code: [Select]
    global $CPG_PHP_SELF, $LINEBREAK, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA;
    if ($CPG_PHP_SELF == 'displayimage.php') {
        $meta .= '<meta property="og:url" content="' . $CONFIG['ecards_more_pic_target'] . 'displayimage.php?pid=' . $CURRENT_PIC_DATA['pid'] . '" />' . $LINEBREAK;
        $meta .= '<meta property="og:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'] . '" />';
    } elseif ($CPG_PHP_SELF == 'thumbnails.php') {
        $thumb = mysql_fetch_assoc(cpg_db_query("SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} WHERE aid = {$CURRENT_ALBUM_DATA['aid']} ORDER BY pid DESC LIMIT 1"));
        $meta .= '<meta property="og:url" content="' . $CONFIG['ecards_more_pic_target'] . 'thumbnails.php?album=' . $CURRENT_ALBUM_DATA['aid'] . '" />' . $LINEBREAK;
        $meta .= '<meta property="og:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $thumb['filepath'] . $thumb['filename'] . '" />';
    }
Title: Re: Open Graph meta data for coppermine
Post by: netb on February 05, 2015, 11:54:47 pm
Thank you, Αndré!
This does the job. I was lurking around the forum almost every day and reading other topics but didn't notice you replied here until now, silly me.

There is a minor issue though, when I open the lastup meta album of a category for example, it gives an error. The elseif seems to make it because when I leave only the function for displayimage it works normally. Here's an example of what's happening: http://www.greatmusclebodies.com/thumbnails.php?album=lastup&cat=3

Code: [Select]
Template error
Failed to find block 'file_line' (#<!-- BEGIN file_line -->(.*?)<!-- END file_line -->#s) in :
                    <div class="{CSS_CLASS}">
                        <h2>{HEADER_TXT}</h2>
                        <span class="cpg_user_message">{MESSAGE}</span>


                        <br /><br />
                    </div>
Title: Re: Open Graph meta data for coppermine
Post by: netb on February 06, 2015, 12:56:57 am
Forgot to mention that it also happens for the others like "toprated", "topn" and "lastcom" if relevant.
Title: Re: Open Graph meta data for coppermine
Post by: netb on February 06, 2015, 02:41:21 am
I think it's related to the negative/positive ID of the albums/categories and I was just looking at the codebase.php of the cpg1.5.x_plugin_social-sharing_v1.5 plugin which seems to address the same issue when generating the meta tags but my understanding of the code is very limited.
Title: Re: Open Graph meta data for coppermine
Post by: Αndré on February 06, 2015, 07:34:19 am
Do you also need the open graph meta data in the header for Coppermine meta albums (lastup, etc.) or can it be ommitted?
Title: Re: Open Graph meta data for coppermine
Post by: netb on February 06, 2015, 09:31:48 am
Well, if it's not hard to show meta data also for the meta albums' header - yes. But if involves much headbanging and it's not trivial you can just shield it in some way, so that it doesn't give the error at least.
Title: Re: Open Graph meta data for coppermine
Post by: netb on February 06, 2015, 11:49:11 pm
I also noticed that the search also gets broken by this so I guess it's not going to be trivial.
Title: Re: Open Graph meta data for coppermine
Post by: Αndré on February 08, 2015, 08:00:29 pm
The search is also just a meta album (in the Coppermine world). For almost all meta albums it should be possible to choose a picture from its content. If it's "not possible" (e.g. for meta album "search"), I'll select a random picture from the database. Of course it would also be possible to choose a static picture for all meta albums. Just let me know what's your preferred behavior.
Title: Re: Open Graph meta data for coppermine
Post by: netb on February 08, 2015, 10:42:47 pm
For the meta albums - choose a picture from its content and if it's "not possible, no results for the album, meta album search, etc." just select a random picture from the database.
Title: Re: Open Graph meta data for coppermine
Post by: Αndré on February 09, 2015, 08:06:11 pm
I decided to always use a random picture for meta albums:

Code: [Select]
    global $CPG_PHP_SELF, $LINEBREAK, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA;
    if ($CPG_PHP_SELF == 'displayimage.php') {
        $meta .= $LINEBREAK . '<meta property="og:url" content="' . $CONFIG['ecards_more_pic_target'] . 'displayimage.php?pid=' . $CURRENT_PIC_DATA['pid'] . '" />';
        $meta .= $LINEBREAK . '<meta property="og:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'] . '" />';
    } elseif ($CPG_PHP_SELF == 'thumbnails.php') {
        if ($CURRENT_ALBUM_DATA['aid']) {
            $album = $CURRENT_ALBUM_DATA['aid'];
            $sql = "SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND aid = '{$CURRENT_ALBUM_DATA['aid']}' ORDER BY pid DESC LIMIT 1";
        } else {
            $superCage = Inspekt::makeSuperCage();
            $album = $superCage->get->getAlpha('album');
            $sql = "SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' ORDER BY RAND() LIMIT 1";
        }
        $thumb = mysql_fetch_assoc(cpg_db_query($sql));
        $meta .= $LINEBREAK . '<meta property="og:url" content="' . $CONFIG['ecards_more_pic_target'] . 'thumbnails.php?album=' . $album . '" />';
        $meta .= $LINEBREAK . '<meta property="og:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $thumb['filepath'] . $thumb['filename'] . '" />';
    }
Title: Re: Open Graph meta data for coppermine
Post by: netb on February 09, 2015, 09:44:29 pm
That's great! Thanks, Αndré! :)
Title: Re: Open Graph meta data for coppermine
Post by: zorbas2 on February 18, 2015, 04:19:36 pm
I'd like to add the open graph meta tags also to my cpg 1.5.34 installation.
I am using the 'rainy day' theme but can't find the
Code: [Select]
/******************************************************************************
** Section <<<pageheader>>> - START
******************************************************************************/
in the theme.php
However, it is found in the sample theme.php so I guess this is used... ?
Where exactly would I have to paste the code for the open graph meta tags?
Title: Re: Open Graph meta data for coppermine
Post by: netb on February 18, 2015, 07:50:43 pm
Yes, you have to copy this function from sample theme.php if you don't have it in yours and paste the additional code inside it.

Title: Re: Open Graph meta data for coppermine
Post by: zorbas2 on February 19, 2015, 02:30:59 pm
Probably I made a mistake - thats why I asked where exaclty to paste it...

My page header section now looks like this:
Code: [Select]
/******************************************************************************
** Section <<<pageheader>>> - START
******************************************************************************/
function pageheader($section, $meta = '')


{
    global $CPG_PHP_SELF, $LINEBREAK, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA;
    if ($CPG_PHP_SELF == 'displayimage.php') {
        $meta .= $LINEBREAK . '<meta property="og:url" content="' . $CONFIG['ecards_more_pic_target'] . 'displayimage.php?pid=' . $CURRENT_PIC_DATA['pid'] . '" />';
        $meta .= $LINEBREAK . '<meta property="og:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'] . '" />';
    } elseif ($CPG_PHP_SELF == 'thumbnails.php') {
        if ($CURRENT_ALBUM_DATA['aid']) {
            $album = $CURRENT_ALBUM_DATA['aid'];
            $sql = "SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND aid = '{$CURRENT_ALBUM_DATA['aid']}' ORDER BY pid DESC LIMIT 1";
        } else {
            $superCage = Inspekt::makeSuperCage();
            $album = $superCage->get->getAlpha('album');
            $sql = "SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' ORDER BY RAND() LIMIT 1";
        }
        $thumb = mysql_fetch_assoc(cpg_db_query($sql));
        $meta .= $LINEBREAK . '<meta property="og:url" content="' . $CONFIG['ecards_more_pic_target'] . 'thumbnails.php?album=' . $album . '" />';
        $meta .= $LINEBREAK . '<meta property="og:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $thumb['filepath'] . $thumb['filename'] . '" />';
    }

    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

    $custom_header = cpg_get_custom_include($CONFIG['custom_header_path']);

    $charset = ($CONFIG['charset'] == 'language file') ? $lang_charset : $CONFIG['charset'];

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    header("Content-Type: text/html; charset=$charset");
    user_save_profile();

    $template_vars = array(
        '{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => theme_page_title($section),
        '{CHARSET}' => $charset,
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{SYS_MENU}' => theme_main_menu('sys_menu'),
        '{SUB_MENU}' => theme_main_menu('sub_menu'),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
        '{CUSTOM_HEADER}' => $custom_header,
        '{JAVASCRIPT}' => theme_javascript_head(),
        '{MESSAGE_BLOCK}' => theme_display_message_block(),
    );

    $template_vars = CPGPluginAPI::filter('theme_pageheader_params', $template_vars);
    echo template_eval($template_header, $template_vars);

    // Show various admin messages
    adminmessages();
}

/******************************************************************************
** Section <<<pageheader>>> - END
******************************************************************************/

But I get the following error:

Quote
Template error
Failed to find block 'file_line' (#<!-- BEGIN file_line -->(.*?)<!-- END file_line -->#s) in :
                    <div class="{CSS_CLASS}">
                        <h2>{HEADER_TXT}</h2>
                        <span class="cpg_user_message">{MESSAGE}</span>


                        <br /><br />
                    </div>
Title: Re: Open Graph meta data for coppermine
Post by: netb on February 20, 2015, 02:25:26 pm
Here's how I've put the code and my first part of the section looks like:

Code: [Select]
/******************************************************************************
** Section <<<pageheader>>> - START
******************************************************************************/
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

global $CPG_PHP_SELF, $LINEBREAK, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA;
    if ($CPG_PHP_SELF == 'displayimage.php') {
        $meta .= '<meta property="og:url" content="' . $CONFIG['ecards_more_pic_target'] . 'displayimage.php?pid=' . $CURRENT_PIC_DATA['pid'] . '" />' . $LINEBREAK;
        $meta .= '<meta property="og:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'] . '" />';
    } elseif ($CPG_PHP_SELF == 'thumbnails.php') {
        $thumb = mysql_fetch_assoc(cpg_db_query("SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} WHERE aid = {$CURRENT_ALBUM_DATA['aid']} ORDER BY pid DESC LIMIT 1"));
        $meta .= '<meta property="og:url" content="' . $CONFIG['ecards_more_pic_target'] . 'thumbnails.php?album=' . $CURRENT_ALBUM_DATA['aid'] . '" />' . $LINEBREAK;
        $meta .= '<meta property="og:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $thumb['filepath'] . $thumb['filename'] . '" />';
    }

    $custom_header = cpg_get_custom_include($CONFIG['custom_header_path']);

    $charset = ($CONFIG['charset'] == 'language file') ? $lang_charset : $CONFIG['charset'];
Title: Re: Open Graph meta data for coppermine
Post by: micropalla on November 16, 2017, 09:54:20 am
Hello!

I added the code and now it shows the image in FB but now I receive and error while trying to see all the images of an author.

Here the code i applied to theme.php

Code: [Select]
/******************************************************************************
** Section <<<pageheader>>> - START
******************************************************************************/
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

global $CPG_PHP_SELF, $LINEBREAK, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA;
    if ($CPG_PHP_SELF == 'displayimage.php') {
        $meta .= '<meta property="og:url" content="' . $CONFIG['ecards_more_pic_target'] . 'displayimage.php?pid=' . $CURRENT_PIC_DATA['pid'] . '" />' . $LINEBREAK;
        $meta .= '<meta property="og:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'] . '" />';
    } elseif ($CPG_PHP_SELF == 'thumbnails.php') {
        $thumb = mysql_fetch_assoc(cpg_db_query("SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} WHERE aid = {$CURRENT_ALBUM_DATA['aid']} ORDER BY pid DESC LIMIT 1"));
        $meta .= '<meta property="og:url" content="' . $CONFIG['ecards_more_pic_target'] . 'thumbnails.php?album=' . $CURRENT_ALBUM_DATA['aid'] . '" />' . $LINEBREAK;
        $meta .= '<meta property="og:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $thumb['filepath'] . $thumb['filename'] . '" />';
    }

    $custom_header = cpg_get_custom_include($CONFIG['custom_header_path']);

    $charset = ($CONFIG['charset'] == 'language file') ? $lang_charset : $CONFIG['charset'];

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    header("Content-Type: text/html; charset=$charset");
    user_save_profile();

    $template_vars = array(
        '{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => theme_page_title($section),
        '{CHARSET}' => $charset,
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{SYS_MENU}' => theme_main_menu('sys_menu'),
        '{SUB_MENU}' => theme_main_menu('sub_menu'),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
        '{CUSTOM_HEADER}' => $custom_header,
        '{JAVASCRIPT}' => theme_javascript_head(),
        '{MESSAGE_BLOCK}' => theme_display_message_block(),
    );

    $template_vars = CPGPluginAPI::filter('theme_pageheader_params', $template_vars);
    echo template_eval($template_header, $template_vars);

    // Show various admin messages
    adminmessages();
}

/******************************************************************************
** Section <<<pageheader>>> - END
******************************************************************************/

Here the error I receive:

Quote
Template error
Failed to find block 'output_buffer' (#<!-- BEGIN output_buffer -->(.*?)<!-- END output_buffer -->#s) in :
                    <div class="{CSS_CLASS}">
                        <h2>{HEADER_TXT}</h2>
                        <span class="cpg_user_message">{MESSAGE}</span>
<!-- BEGIN file_line -->
                        <br />
                        <br />
                        {FILE_TXT}{FILE} - {LINE_TXT}{LINE}
<!-- END file_line -->

                        <br /><br />
                    </div>

What do I wrong?
Thx in advance
Title: Re: Open Graph meta data for coppermine
Post by: Αndré on November 21, 2017, 12:28:39 pm
Cannot confirm. Please post a link to your gallery and a link where we can see the error "in action". I assume it'll look like http://planepix.nl/thumbnails.php?album=lastupby&uid=4 (i.e. the "lastupby" meta album). That's at least what I tested and as you can see, the mod works as expected in that gallery.
Title: Re: Open Graph meta data for coppermine
Post by: gabbox097 on June 11, 2021, 07:30:32 pm
Hi @André, I'm using your code but it seems like the SQL query isn't working ($thumb = mysql_fetch_assoc(cpg_db_query($sql));)

This is what I have on my theme.php file:
Code: [Select]
global $CPG_PHP_SELF, $LINEBREAK, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA;
    if ($CPG_PHP_SELF == 'displayimage.php') {
        $meta .= $LINEBREAK . '<meta property="og:url" content="' . $CONFIG['ecards_more_pic_target'] . 'displayimage.php?pid=' . $CURRENT_PIC_DATA['pid'] . '" />';
        $meta .= $LINEBREAK . '<meta property="og:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'] . '" />';
        $meta .= $LINEBREAK . '<meta property="twitter:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'] . '" />';
    } elseif ($CPG_PHP_SELF == 'thumbnails.php') {
        if ($CURRENT_ALBUM_DATA['aid']) {
            $album = $CURRENT_ALBUM_DATA['aid'];
            $sql = "SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND aid = '{$CURRENT_ALBUM_DATA['aid']}' ORDER BY pid DESC LIMIT 1";
        } else {
            $superCage = Inspekt::makeSuperCage();
            $album = $superCage->get->getAlpha('album');
            $sql = "SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' ORDER BY RAND() LIMIT 1";
        }
        $thumb = mysql_fetch_assoc(cpg_db_query($sql));
        $meta .= $LINEBREAK . '<meta property="og:url" content="' . $CONFIG['ecards_more_pic_target'] . 'thumbnails.php?album=' . $album . '" />';
        $meta .= $LINEBREAK . '<meta property="og:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $thumb['filepath'] . $thumb['filename'] . '" />';
        $meta .= $LINEBREAK . '<meta property="twitter:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $thumb['filepath'] . $thumb['filename'] . '" />';
    }