Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1] 2   Go Down

Author Topic: Open Graph meta data for coppermine  (Read 36527 times)

0 Members and 1 Guest are viewing this topic.

Anturaju93

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Open Graph meta data for coppermine
« 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Open Graph meta data for coppermine
« Reply #1 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?
Logged

Anturaju93

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Open Graph meta data for coppermine
« Reply #2 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 ?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Open Graph meta data for coppermine
« Reply #3 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.
Logged

Anturaju93

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Open Graph meta data for coppermine
« Reply #4 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.       
Logged

Anturaju93

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Open Graph meta data for coppermine
« Reply #5 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 ?
Logged

Anturaju93

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Open Graph meta data for coppermine
« Reply #6 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. ...
Logged

E. William

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 33
Re: Open Graph meta data for coppermine
« Reply #7 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.
Logged

Anturaju93

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Open Graph meta data for coppermine
« Reply #8 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 :)
Logged

E. William

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 33
Re: Open Graph meta data for coppermine
« Reply #9 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.
Logged

Anturaju93

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Open Graph meta data for coppermine
« Reply #10 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.
Logged

E. William

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 33
Re: Open Graph meta data for coppermine
« Reply #11 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).
Logged

E. William

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 33
Re: Open Graph meta data for coppermine
« Reply #12 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']} . '" />';
    }
Logged

E. William

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 33
Re: Open Graph meta data for coppermine
« Reply #13 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Open Graph meta data for coppermine
« Reply #14 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?
Logged

Anturaju93

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Open Graph meta data for coppermine
« Reply #15 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
Logged

Anturaju93

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Re: Open Graph meta data for coppermine
« Reply #16 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Open Graph meta data for coppermine
« Reply #17 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'] . '" />';
    }
Logged

Anturaju93

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Open Graph meta data for coppermine
« Reply #18 on: December 18, 2013, 10:08:58 am »

Logged

netb

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 82
Re: Re: Open Graph meta data for coppermine
« Reply #19 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

Logged
Pages: [1] 2   Go Up
 

Page created in 0.027 seconds with 19 queries.