Results 1 to 5 of 5

Thread: Code to use News Images as Facebook go:image tag

  1. #1
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Code to use News Images as Facebook go:image tag

    Here is the script you need to add to your news_full.html5 template to add a Facebook image by using the News image.

    Code:
    <?php
    $fbimage = $this->getImage($this->urlEncode($this->singleSRC), 512, 512 , 'box');
    $GLOBALS['TL_HEAD'][] = '<meta property="og:image" content="' . $this->Environment->base . $fbimage . '" />';
    ?>
    <div class="layout_full"…..

  2. #2
    New user
    Join Date
    11-08-12.
    Posts
    2

    Default Re: Code to use News Images as Facebook go:image tag

    Hello,
    It doesn't seem to work with Contao 3.0
    Is there an alternative ?
    Thank you

  3. #3
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Code to use News Images as Facebook go:image tag

    Not sure, but this code I wrote for 3.x.

  4. #4
    New user
    Join Date
    11-08-12.
    Posts
    2

    Default Re: Code to use News Images as Facebook go:image tag

    Indeed, it works perfectly.
    Thanks !

  5. #5
    User Toflar's Avatar
    Join Date
    06-19-09.
    Location
    Lyss, Switzerland
    Posts
    170

    Default

    For 3.2+ for your information

    PHP Code:
    <?php
    if (($image FilesModel::findByUuid($this->singleSRC)) !== null) {
        
    $fbimage =  Image::get(System::urlEncode($image->path), 512512 'box');
        
    $GLOBALS['TL_HEAD'][] = '<meta property="og:image" content="' Environment::get('base') . $fbimage '">';
    }
    ?>
    Last edited by Toflar; 08/19/2014 at 14:57.
    Regards

    Yanick - Contao core developer @terminal42 gmbh

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •