Frontend\Core\Engine\Header::addOpenGraphImage PHP Méthode

addOpenGraphImage() public méthode

Add Open Graph image
public addOpenGraphImage ( string $image, boolean $overwrite = false, integer $width, integer $height )
$image string The path to the image.
$overwrite boolean Should we overwrite the previous value?
$width integer The width of the image.
$height integer The height of the image.
    public function addOpenGraphImage($image, $overwrite = false, $width = 0, $height = 0)
    {
        // recast width and height
        $width = (int) $width;
        $height = (int) $height;
        // remove site url from path
        $image = str_replace(SITE_URL, '', $image);
        // check if it no longer points to an absolute uri
        if (mb_substr($image, 0, 7) != 'http://' && mb_substr($image, 0, 8) != 'https://') {
            if (!is_file(PATH_WWW . strtok($image, '?'))) {
                return;
            }
            $image = SITE_URL . $image;
        }
        // add to metadata
        $this->addMetaData(array('property' => 'og:image', 'content' => $image), $overwrite, array('property', 'content'));
        if (SITE_PROTOCOL == 'https') {
            $this->addMetaData(array('property' => 'og:image:secure_url', 'content' => $image), $overwrite, array('property', 'content'));
        }
        if ($width !== 0) {
            $this->addMetaData(array('property' => 'og:image:width', 'content' => $width), $overwrite, array('property', 'content'), $image);
        }
        if ($height !== 0) {
            $this->addMetaData(array('property' => 'og:image:height', 'content' => $height), $overwrite, array('property', 'content'), $image);
        }
    }