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);
}
}