• Hi!
    I’m trying to add og: meta tags to my website and I’m having troubles with getting the og:image meta tag when using ImageBrowser.
    I’m able to get the image url without any problem and create meta tag by adding:
    <meta property="og:image" content="<?php echo esc_attr($storage->get_image_url($image, 'full', TRUE)); ?>" /> in nextgen_basic_imagebrowser.php but it doesn’t insert it in <head></head> (obviously) so facebook won’t recognize it.
    How could I add this meta tag before the closing </head> ?
    I suppose this is a fairly basic question but I spent last few days trying it and I’m pretty much stuck in a dead-end..

    https://wordpress.org/plugins/nextgen-gallery/

Viewing 1 replies (of 1 total)
  • Benjamin

    (@benjaminowens)

    Unfortunately by the time NextGen shortcodes or ATP created galleries are rendered WordPress has already started to reply to the browser with the site headers & top content.

    You can however use output buffering to begin capturing output early (so no http headers are sent to the browser) and then do an inspection on the resulting imagebrowser gallery and inject whatever data you need into the <head></head> portion.

    <?php
    function addog($buffer) {
        return (str_replace("</head>", "<og:img src='...'></head>", $buffer));
    }
    function addog_start() { ob_start('addog'); }
    function addog_end() { ob_end_flush(); }
    add_action('wp_head', 'addog_start');
    add_action('wp_footer', 'addog_end');

    You’ll just need to fill in the opengraph tags by reading $buffer to determine the image src, alt, title, etc.

    That should get you started, I hope it helps!

Viewing 1 replies (of 1 total)

The topic ‘Get Imagebrowser image URL in og:image’ is closed to new replies.