2016-01-26 14:31:53 +00:00
|
|
|
<?php
|
|
|
|
|
2016-01-30 22:17:23 +00:00
|
|
|
use Lychee\Modules\Database;
|
|
|
|
use Lychee\Modules\Photo;
|
|
|
|
|
2016-01-26 14:31:53 +00:00
|
|
|
function getGraphHeader($photoID) {
|
|
|
|
|
|
|
|
$photo = new Photo($photoID);
|
|
|
|
if ($photo->getPublic('')===false) return false;
|
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
$query = Database::prepare(Database::get(), "SELECT title, description, url, medium FROM ? WHERE id = '?'", array(LYCHEE_TABLE_PHOTOS, $photoID));
|
2016-01-31 17:49:31 +00:00
|
|
|
$result = Database::execute(Database::get(), $query, __METHOD__, __LINE__);
|
2016-01-26 14:31:53 +00:00
|
|
|
|
2016-01-31 17:49:31 +00:00
|
|
|
if ($result===false) return false;
|
2016-01-31 12:55:23 +00:00
|
|
|
|
|
|
|
$row = $result->fetch_object();
|
|
|
|
|
|
|
|
if ($row===null) {
|
2016-01-31 17:49:31 +00:00
|
|
|
Log::error(Database::get(), __METHOD__, __LINE__, 'Could not find photo in database');
|
2016-01-31 12:55:23 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-01-26 14:31:53 +00:00
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
if ($row->medium==='1') $dir = 'medium';
|
|
|
|
else $dir = 'big';
|
2016-01-26 14:31:53 +00:00
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
$parseUrl = parse_url('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
2016-06-01 19:42:01 +00:00
|
|
|
$url = '//' . $parseUrl['host'] . $parseUrl['path'] . '?' . $parseUrl['query'];
|
|
|
|
$picture = '//' . $parseUrl['host'] . $parseUrl['path'] . '/../uploads/' . $dir . '/' . $row->url;
|
2016-01-26 14:31:53 +00:00
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
$url = htmlentities($url);
|
|
|
|
$picture = htmlentities($picture);
|
2016-01-26 14:31:53 +00:00
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
$row->title = htmlentities($row->title);
|
|
|
|
$row->description = htmlentities($row->description);
|
2016-01-26 14:31:53 +00:00
|
|
|
|
|
|
|
$return = '<!-- General Meta Data -->';
|
|
|
|
$return .= '<meta name="title" content="' . $row->title . '">';
|
|
|
|
$return .= '<meta name="description" content="' . $row->description . ' - via Lychee">';
|
|
|
|
$return .= '<link rel="image_src" type="image/jpeg" href="' . $picture . '">';
|
|
|
|
|
|
|
|
$return .= '<!-- Twitter Meta Data -->';
|
|
|
|
$return .= '<meta name="twitter:card" content="photo">';
|
|
|
|
$return .= '<meta name="twitter:title" content="' . $row->title . '">';
|
|
|
|
$return .= '<meta name="twitter:image:src" content="' . $picture . '">';
|
|
|
|
|
|
|
|
$return .= '<!-- Facebook Meta Data -->';
|
|
|
|
$return .= '<meta property="og:title" content="' . $row->title . '">';
|
|
|
|
$return .= '<meta property="og:description" content="' . $row->description . ' - via Lychee">';
|
|
|
|
$return .= '<meta property="og:image" content="' . $picture . '">';
|
|
|
|
$return .= '<meta property="og:url" content="' . $url . '">';
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|