Using Open Graph metatags to display thumbnail

Hello -

I'm trying to implement the Open Graph metatags on image.php so that the thumbnail is used when posting to Facebook, as explained here:

support.addthis.com/customer/portal/articles/1303425-facebook-open-graph-tags

I have tried this:
<meta property="og:image" content=<?php printImageThumb(getAnnotatedImageTitle()); ?> />

and other futile variations but to no avail.

I'm a bit shaky when working with variables here, so can someone tell me the correct way to use the thumbnail variable here?

I have successfully put in the album name using this:
<meta property="og:title" content="<? $_zp_current_album?>" />

But have run out of ideas to get the thumbnail variable to work.

Comments

  • acrylian Administrator, Developer
    The html_meta_tags plugin supports all those open graph tags.

    Regarding your unsuccessful attemps:
    ` />`
    Carefully read what the open graph tag requires which is an url to an image. This function does print a full html image tag which naturally does not work as it is invalid here.

    `" />`
    `$_zp_current_album` is the album object. `$_zp_current_album->name` gets the folder name and `$_zp_current_album->getTitle()` the, well, title. For the basics of the object model there is a tutorial on the user guide. And without using `echo` all do nothing.
  • Thanks for the reply, although I still don't know how to get what I want.

    If you don't want to answer me, then that fine. I'm not demanding anything, nor am I 'm not trying to stir anything up. Just get things to work. If you think this is a stupid question, or I've used up my quota for questions then don't answer it. Not a problem.

    If you do want to answer me, then you said "This function does print a full html image tag which naturally does not work as it is invalid here."

    If you feel like it, could you tell me what *will* work? I would imagine there are others that would find this useful. I thought the answer might be here:

    http://www.zenphoto.org/news/zenphotos-global-variables

    But I don't see the variable to use in this situation. Could you either tell me what to use or else where on this site I can find the answer?
  • Tried to understand your statement about url and echo, and came up with these. Sadly they all failed with and without quotation marks:

    <meta property="og:image" content="<?php echo html_encode(getFullImageURL()); ?>" />

    <meta property="og:image" content="<?php echo getMainSiteURL() . $_zp_current_image->getImageLink(); ?>" />

    <meta property="og:image" content="<?php echo (getFullImageURL()); ?>" />

    <meta property="og:image" content=<?php echo getAlbumThumb( ); ?> />
  • acrylian Administrator, Developer
    There is no quota of questions. I did answer in detail but you will hopefully understand that /we can't fully explain everything. That's why there is a documentation and user guide (Yes, it could probably be better but well…).

    So again, why don't you just use the html_meta_tags plugin and set the options for open graph? That does exactly add those four open graph ones depending on context already. Why re-invent the wheel? And if it does not what you want somehow look at the plugin how it does it.

    The object model (not Zenphoto but PHP in general) inherits from parent classes. The tree is documented on the object model tutorial and all details of each class are documented on the documentation.

    Also remember that the first, third and fourth functions are context dependent and will work only on album.php repectively for the fullimage functions on image.php. Please re-read the theming tutorial if you haven't already about these basics.

    `<?php echo getMainSiteURL() . $_zp_current_image->getImageLink(); ?>`
    Will not get a vaild link since the "Mainsite" refers to the a parent non ZP site if ZP only runs the gallery section of your site run by another CMS or being static HTML otherwise. This is therefore not the index page of Zenphoto which you get by `getGalleryIndexURL`. `Gallery` always refers to the ZP site in general (please see the zenphoto glossary on the user guide about these terms).
  • Thanks acrylian -

    I'll use the plugin. That works great, even with AddThis's smart layers.

    It seems some of the things I tried worked, but I wasn't seeing the changes because Facebook only scrapes every 24 hours. Moot point now, but if anyone is interested, here's how to see facebook og changes in realtiime:

    https://developers.facebook.com/tools/debug

    Cheers.
Sign In or Register to comment.